1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of CaptainHook. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace sebastianfeldmann\CaptainHook\Runner\Action; |
11
|
|
|
|
12
|
|
|
use sebastianfeldmann\CaptainHook\Config; |
13
|
|
|
use sebastianfeldmann\CaptainHook\Console\IO; |
14
|
|
|
use sebastianfeldmann\CaptainHook\Exception\ActionExecution; |
15
|
|
|
use sebastianfeldmann\CaptainHook\Git\Repository; |
16
|
|
|
use sebastianfeldmann\CaptainHook\Hook\Action; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class PHP |
20
|
|
|
* |
21
|
|
|
* @package CaptainHook |
22
|
|
|
* @author Sebastian Feldmann <[email protected]> |
23
|
|
|
* @link https://github.com/sebastianfeldmann/captainhook |
24
|
|
|
* @since Class available since Release 0.9.0 |
25
|
|
|
*/ |
26
|
|
|
class PHP implements Action |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Execute the configured action. |
30
|
|
|
* |
31
|
|
|
* @param \sebastianfeldmann\CaptainHook\Config $config |
32
|
|
|
* @param \sebastianfeldmann\CaptainHook\Console\IO $io |
33
|
|
|
* @param \sebastianfeldmann\CaptainHook\Git\Repository $repository |
34
|
|
|
* @param \sebastianfeldmann\CaptainHook\Config\Action $action |
35
|
|
|
* @throws \sebastianfeldmann\CaptainHook\Exception\ActionExecution |
36
|
|
|
*/ |
37
|
4 |
|
public function execute(Config $config, IO $io, Repository $repository, Config\Action $action) |
38
|
|
|
{ |
39
|
4 |
|
$class = $action->getAction(); |
40
|
|
|
|
41
|
|
|
try { |
42
|
|
|
/* @var \sebastianfeldmann\CaptainHook\Hook\Action $exe */ |
43
|
4 |
|
$exe = new $class(); |
44
|
|
|
|
45
|
4 |
|
if (!$exe instanceof Action) { |
46
|
1 |
|
throw new ActionExecution('PHP class ' . $class . ' has to implement the \'Action\' interface'); |
47
|
|
|
} |
48
|
3 |
|
$exe->execute($config, $io, $repository, $action); |
49
|
|
|
|
50
|
3 |
|
} catch (\Exception $e) { |
51
|
2 |
|
throw new ActionExecution('Execution failed: ' . $e->getMessage()); |
52
|
1 |
|
} catch (\Error $e) { |
|
|
|
|
53
|
1 |
|
throw new ActionExecution('PHP Error: ' . $e->getMessage()); |
54
|
|
|
} |
55
|
1 |
|
} |
56
|
|
|
} |
57
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.