Completed
Pull Request — dev (#11)
by
unknown
04:51
created

AbstractCliHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
isAppropriate() 0 1 ?
A isCliHandler() 0 4 1
1
<?php
2
3
namespace Vectorface\SnappyRouter\Handler;
4
5
use Vectorface\SnappyRouter\Config\Config;
6
7
/**
8
 * The base class for all handlers for CLI routes.
9
 * @copyright Copyright (c) 2014, VectorFace, Inc.
10
 * @author Dan Bruce <[email protected]>
11
 */
12
abstract class AbstractCliHandler extends AbstractHandler
13
{
14
    /**
15
     * Constructor for the class.
16
     * @param array $options An array of options for the plugin.
17
     */
18 8
    public function __construct($options)
19
    {
20 8
        if (isset($options[Config::KEY_TASKS])) {
21 8
            $options[Config::KEY_CONTROLLERS] = $options[Config::KEY_TASKS];
22 8
            unset($options[Config::KEY_TASKS]);
23 8
        }
24 8
        parent::__construct($options);
25 8
    }
26
27
    /**
28
     * Determines whether the current handler is appropriate for the given
29
     * path components.
30
     * @param array $components The path components as an array.
31
     * @return boolean Returns true if the handler is appropriate and false
32
     *         otherwise.
33
     */
34
    abstract public function isAppropriate($components);
35
36
    /**
37
     * Returns whether a handler should function in a CLI environment.
38
     * @return bool Returns true if the handler should function in a CLI
39
     *         environment and false otherwise.
40
     */
41 5
    public function isCliHandler()
42
    {
43 5
        return true;
44
    }
45
}
46