GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ScopeRepository::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Lookyman\NetteOAuth2Server\Storage\Doctrine\Scope;
5
6
use Kdyby\Doctrine\InvalidStateException;
7
use Kdyby\Doctrine\QueryException;
8
use Kdyby\Doctrine\Registry;
9
use League\OAuth2\Server\Entities\ClientEntityInterface;
10
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
11
12
class ScopeRepository implements ScopeRepositoryInterface
13
{
14
	/**
15
	 * @var Registry
16
	 */
17
	private $registry;
18
19
	/**
20
	 * @var callable
21
	 */
22
	private $scopeFinalizer;
23
24
	/**
25
	 * @param Registry $registry
26
	 * @param callable|null $scopeFinalizer
27
	 */
28
	public function __construct(Registry $registry, callable $scopeFinalizer = null)
29
	{
30
		$this->registry = $registry;
31
		$this->scopeFinalizer = $scopeFinalizer ?: function (array $scopes) { return $scopes; };
32
	}
33
34
	/**
35
	 * @param string $identifier
36
	 * @return ScopeEntity|null
37
	 * @throws InvalidStateException
38
	 * @throws QueryException
39
	 */
40
	public function getScopeEntityByIdentifier($identifier)
41
	{
42
		return $this->registry->getManager()->getRepository(ScopeEntity::class)->fetchOne($this->createQuery()->byIdentifier($identifier));
43
	}
44
45
	/**
46
	 * @param ScopeEntity[] $scopes
47
	 * @param string $grantType
48
	 * @param ClientEntityInterface $clientEntity
49
	 * @param string|null $userIdentifier
50
	 * @return ScopeEntity[]
51
	 */
52
	public function finalizeScopes(
53
		array $scopes,
54
		$grantType,
55
		ClientEntityInterface $clientEntity,
56
		$userIdentifier = null
57
	)
58
	{
59
		return call_user_func($this->scopeFinalizer, $scopes, $grantType, $clientEntity, $userIdentifier);
60
	}
61
62
	/**
63
	 * @return ScopeQuery
64
	 */
65
	protected function createQuery(): ScopeQuery
66
	{
67
		return new ScopeQuery();
68
	}
69
}
70