Passed
Pull Request — master (#16)
by Pol
13:11
created

Plugin::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types=1);
9
10
namespace loophp\fpt\Psalm;
11
12
use loophp\fpt\Psalm\EventHandler\ComposeSimple\AfterExpressionAnalysisProvider;
13
use Psalm\Plugin\EventHandler\MethodReturnTypeProviderInterface;
14
use Psalm\Plugin\PluginEntryPointInterface;
15
use Psalm\Plugin\RegistrationInterface;
16
use SimpleXMLElement;
17
18
use function str_replace;
19
20
final class Plugin implements PluginEntryPointInterface
21
{
22
    public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
23
    {
24
        foreach ($this->getHooks() as $hook) {
25
            /** @psalm-suppress UnresolvableInclude */
26
            $file = __DIR__ . '/' . str_replace([__NAMESPACE__, '\\'], ['', '/'], $hook) . '.php';
27
28
            require_once $file;
29
30
            $registration->registerHooksFromClass($hook);
31
        }
32
    }
33
34
    /**
35
     * @return iterable<class-string<MethodReturnTypeProviderInterface>>
36
     */
37
    private function getHooks(): iterable
38
    {
39
        yield AfterExpressionAnalysisProvider::class;
40
    }
41
}
42