mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-24 07:35:03 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,33 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class DefaultScopeResolver implements ScopeResolverInterface
|
||||
{
|
||||
|
||||
public function supports($entity, ?array $options = []): bool
|
||||
public static function getDefaultPriority(): int
|
||||
{
|
||||
return $entity instanceof HasScopeInterface || $entity instanceof HasScopesInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*
|
||||
* @param HasScopeInterface|HasScopesInterface $entity
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
{
|
||||
if ($entity instanceof HasScopeInterface) {
|
||||
return $entity->getScope();
|
||||
} elseif ($entity instanceof HasScopesInterface) {
|
||||
return $entity->getScopes();
|
||||
} else {
|
||||
throw new \UnexpectedValueException("should be an instanceof %s or %s",
|
||||
HasScopesInterface::class, HasScopeInterface::class);
|
||||
}
|
||||
return -256;
|
||||
}
|
||||
|
||||
public function isConcerned($entity, ?array $options = []): bool
|
||||
@@ -35,8 +25,28 @@ class DefaultScopeResolver implements ScopeResolverInterface
|
||||
return $entity instanceof HasScopeInterface || $entity instanceof HasScopesInterface;
|
||||
}
|
||||
|
||||
public static function getDefaultPriority(): int
|
||||
/**
|
||||
* @param HasScopeInterface|HasScopesInterface $entity
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
{
|
||||
return -256;
|
||||
if ($entity instanceof HasScopeInterface) {
|
||||
return $entity->getScope();
|
||||
}
|
||||
|
||||
if ($entity instanceof HasScopesInterface) {
|
||||
return $entity->getScopes();
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException(
|
||||
'should be an instanceof %s or %s',
|
||||
HasScopesInterface::class,
|
||||
HasScopeInterface::class
|
||||
);
|
||||
}
|
||||
|
||||
public function supports($entity, ?array $options = []): bool
|
||||
{
|
||||
return $entity instanceof HasScopeInterface || $entity instanceof HasScopesInterface;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user