1 | <?php |
||
14 | class ClassPattern implements PatternInterface { |
||
15 | |||
16 | /** |
||
17 | * Result of this pattern will be body of the class |
||
18 | */ |
||
19 | const OUTPUT_BODY = 1; |
||
20 | |||
21 | /** |
||
22 | * Result of this pattern will be full class |
||
23 | */ |
||
24 | const OUTPUT_FULL = 2; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * @var QueryStrategy |
||
29 | */ |
||
30 | private $nameQuery = null; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $outputType = self::OUTPUT_BODY; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * By default we search for classes with any name |
||
40 | */ |
||
41 | 40 | public function __construct() { |
|
44 | |||
45 | |||
46 | /** |
||
47 | * @codeCoverageIgnore |
||
48 | * @deprecated |
||
49 | * @param string $name |
||
50 | * @return $this |
||
51 | */ |
||
52 | public function nameIs($name) { |
||
56 | |||
57 | |||
58 | /** |
||
59 | * @param QueryStrategy|string $name |
||
60 | * @return $this |
||
61 | */ |
||
62 | 12 | public function withName($name) { |
|
63 | 10 | if (is_string($name)) { |
|
64 | 6 | $this->nameQuery = Strict::create()->valueIs($name); |
|
65 | 7 | } elseif ($name instanceof QueryStrategy) { |
|
66 | 5 | $this->nameQuery = $name; |
|
67 | 2 | } else { |
|
68 | 2 | throw new \InvalidArgumentException('Expect string or QueryInterface'); |
|
69 | 2 | } |
|
70 | |||
71 | 10 | return $this; |
|
72 | } |
||
73 | |||
74 | |||
75 | /** |
||
76 | * @return $this |
||
77 | */ |
||
78 | 3 | public function outputBody() { |
|
79 | 3 | $this->outputType = self::OUTPUT_BODY; |
|
80 | 3 | return $this; |
|
81 | } |
||
82 | |||
83 | |||
84 | /** |
||
85 | * @return $this |
||
86 | */ |
||
87 | 6 | public function outputFull() { |
|
91 | |||
92 | |||
93 | /** |
||
94 | * @codeCoverageIgnore |
||
95 | * @deprecated |
||
96 | * @param QueryStrategy $strategy |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function whereName(QueryStrategy $strategy) { |
||
103 | |||
104 | |||
105 | /** |
||
106 | * @inheritdoc |
||
107 | */ |
||
108 | 28 | public function __invoke(QuerySequence $querySequence) { |
|
140 | |||
141 | } |