ToolsFilter::setInclude()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
  namespace Funivan\Cs\FileTool;
4
5
  /**
6
   * @author Ivan Shcherbak <[email protected]> 2016
7
   */
8
  class ToolsFilter {
9
10
    /**
11
     * @var null|string[]
12
     */
13
    private $include = null;
14
15
    /**
16
     * @var null|string[]
17
     */
18
    private $exclude = null;
19
20
21
    /**
22
     * @return null|string[]
23
     */
24
    public function getInclude() {
25
      return $this->include;
26
    }
27
28
29
    /**
30
     * @param null|string[] $include
31
     * @return $this
32
     */
33
    public function setInclude(array $include = null) {
34
      $this->include = $include;
35
      return $this;
36
    }
37
38
39
    /**
40
     * @return null|string[]
41
     */
42
    public function getExclude() {
43
      return $this->exclude;
44
    }
45
46
47
    /**
48
     * @param null|string[] $exclude
49
     * @return $this
50
     */
51
    public function setExclude(array $exclude = null) {
52
      $this->exclude = $exclude;
53
      return $this;
54
    }
55
56
57
    /**
58
     * @param FileTool $tool
59
     * @return bool
60
     */
61
    public function isValid(FileTool $tool) {
62
63
      $toolName = $tool->getName();
64
65
      if (null !== $this->exclude and in_array($toolName, $this->exclude)) {
66
        return false;
67
      }
68
69
      if (null !== $this->include and !in_array($toolName, $this->include)) {
70
        return false;
71
      }
72
73
74
      return true;
75
    }
76
77
  }