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.
Completed
Push — 4.0 ( 55acbb...164817 )
by Olivier
03:36 queued 01:42
created

InstallableModulesFilter::__invoke()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 26
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.439
c 0
b 0
f 0
cc 5
eloc 11
nc 5
nop 1
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
53
		try
54
		{
55
			$is_installed = $module->is_installed($errors);
56
57
			if ($is_installed && !count($errors))
58
			{
59
				return false;
60
			}
61
		}
62
		catch (\Exception $e)
63
		{
64
			# there was an error, the module might not be properly installed.
65
		}
66
67
		return true;
68
	}
69
}
70