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

AbstractCliHandler::isCliHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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