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.

InstallableModulesFilter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 13 3
1
<?php
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\Module\ModuleCollection;
13
14
use ICanBoogie\ErrorCollection;
15
use ICanBoogie\Module\Descriptor;
16
use ICanBoogie\Module\ModuleCollection;
17
18
/**
19
 * Filters installable module descriptors.
20
 */
21
class InstallableModulesFilter
22
{
23
	/**
24
	 * @var ModuleCollection
25
	 */
26
	private $modules;
27
28
	/**
29
	 * InstallableModulesFilter constructor.
30
	 *
31
	 * @param ModuleCollection $modules
32
	 */
33
	public function __construct(ModuleCollection $modules)
34
	{
35
		$this->modules = $modules;
36
	}
37
38
	/**
39
	 * @param array $descriptor An array of {@link Descriptor::*} keys.
40
	 *
41
	 * @return bool `true` if the module may be installed, `false` otherwise.
42
	 */
43
	public function __invoke(array $descriptor)
44
	{
45
		if ($descriptor[Descriptor::DISABLED])
46
		{
47
			return false;
48
		}
49
50
		$module = $this->modules[$descriptor[Descriptor::ID]];
51
		$errors = new ErrorCollection;
52
		$is_installed = $module->is_installed($errors);
53
54
		return $is_installed === false || $errors->count();
55
	}
56
}
57