Completed
Push — master ( 0ebeda...45d090 )
by Peter
02:31
created

RuleCollection::has()   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 1
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 */
8
namespace AnimeDb\SmartSleep;
9
10
use AnimeDb\SmartSleep\Rule\RuleInterface;
11
12
class RuleCollection
13
{
14
    /**
15
     * @var RuleInterface[]
16
     */
17
    protected $rules = [];
18
19
    /**
20
     * @param string $name
21
     * @param RuleInterface $rule
22
     *
23
     * @return RuleCollection
24
     */
25 3
    public function set($name, RuleInterface $rule)
26
    {
27 3
        $this->rules[$name] = clone $rule;
28
29 3
        return $this;
30
    }
31
32
    /**
33
     * @param string $name
34
     *
35
     * @return RuleInterface|null
36
     */
37 3
    public function get($name)
38
    {
39 3
        return isset($this->rules[$name]) ? clone $this->rules[$name] : null;
40
    }
41
42
    /**
43
     * @param string $name
44
     *
45
     * @return bool
46
     */
47 1
    public function has($name)
48
    {
49 1
        return isset($this->rules[$name]);
50
    }
51
}
52