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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 4
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getScopeEntityByIdentifier() 0 4 1
A finalizeScopes() 0 9 1
A createQuery() 0 4 1
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