AbstractStrategy::argGet()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Humweb\Features\Strategy;
4
5
/**
6
 * Abstract strategy.
7
 */
8
abstract class AbstractStrategy implements StrategyInterface
9
{
10
11
    /**
12
     * Strategy name
13
     *
14
     * @var string
15
     */
16
    protected $name;
17
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    abstract public function handle($args);
23
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getName()
29
    {
30
        if (empty($this->name)) {
31
            $this->setName();
32
        }
33
34
        return $this->name;
35
    }
36
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function setName($name = null)
42
    {
43
        if (empty($name)) {
44
            $classname = explode('\\', get_class($this));
45
            $name = substr(array_pop($classname), 0, -strlen('Strategy'));
46
        }
47
48
        $this->name = $name;
49
        return $this;
50
51
    }
52
53
    protected function argGet($ary = [], $key, $default = null)
54
    {
55
        return isset($ary[$key]) ? $ary[$key] : $default;
56
    }
57
}
58