Passed
Push — master ( b34030...56c38f )
by Sebastian
03:50
created

HookHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 25
c 1
b 0
f 1
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setHook() 0 8 3
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;
11
12
use sebastianfeldmann\CaptainHook\Exception;
13
use sebastianfeldmann\CaptainHook\Hook\Util as HookUtil;
14
use sebastianfeldmann\CaptainHook\Runner;
15
16
/**
17
 * Class HookHandler
18
 *
19
 * @package CaptainHook
20
 * @author  Sebastian Feldmann <[email protected]>
21
 * @link    https://github.com/sebastianfeldmann/captainhook
22
 * @since   Class available since Release 0.9.0
23
 */
24
abstract class HookHandler extends Runner
25
{
26
    /**
27
     * Hook that should be handled
28
     *
29
     * @var string
30
     */
31
    protected $hookToHandle;
32
33
    /**
34
     * Hook setter.
35
     *
36
     * @param  string $hook
37
     * @return \sebastianfeldmann\CaptainHook\Runner\HookHandler
38
     * @throws \sebastianfeldmann\CaptainHook\Exception\InvalidHookName
39
     */
40 10
    public function setHook($hook)
41
    {
42 10
        if (null !== $hook && !HookUtil::isValid($hook)) {
43 2
            throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
44
        }
45 8
        $this->hookToHandle = $hook;
46 8
        return $this;
47
    }
48
}
49