1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PHPKitchen\CodeSpecs\Expectation\Matcher; |
4
|
|
|
|
5
|
|
|
use PHPKitchen\CodeSpecs\Expectation\Matcher\Base\Matcher; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* ClassMatcher is designed to check given class matches expectation. |
9
|
|
|
* |
10
|
|
|
* @package PHPKitchen\CodeSpecs\Expectation |
11
|
|
|
* @author Dima Kolodko <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class ClassMatcher extends Matcher { |
14
|
|
|
/** |
15
|
|
|
* @return $this |
16
|
|
|
*/ |
17
|
|
|
public function isExist(): self { |
18
|
|
|
$this->startStep('is exist') |
19
|
|
|
->assertClassExists(); |
20
|
|
|
|
21
|
|
|
return $this; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return $this |
26
|
|
|
*/ |
27
|
|
|
public function isNotExist(): self { |
28
|
|
|
$this->startStep('is not exist') |
29
|
|
|
->assertClassDoesNotExist(); |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return $this |
36
|
|
|
*/ |
37
|
|
|
public function isInterface(): self { |
38
|
|
|
$this->startStep('is interface') |
39
|
|
|
->assertClassIsInterface(); |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return $this |
46
|
|
|
*/ |
47
|
|
|
public function isNotInterface(): self { |
48
|
|
|
$this->startStep('is not interface') |
49
|
|
|
->assertClassIsNotInterface(); |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function hasStaticAttribute($attribute): self { |
58
|
|
|
$this->startStep("has static attribute \"{$attribute}\"") |
59
|
|
|
->assertClassHasStaticAttribute($attribute); |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return $this |
66
|
|
|
*/ |
67
|
|
|
public function doesNotHaveStaticAttribute($attribute): self { |
68
|
|
|
$this->startStep("does not have static attribute \"{$attribute}\"") |
69
|
|
|
->assertClassNotHasStaticAttribute($attribute); |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function hasAttribute($attribute): self { |
78
|
|
|
$this->startStep("has attribute \"{$attribute }\"") |
79
|
|
|
->assertClassHasAttribute($attribute); |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
public function doesNotHaveAttribute($attribute): self { |
88
|
|
|
$this->startStep("does not have attribute \"{$attribute}\"") |
89
|
|
|
->assertClassNotHasAttribute($attribute); |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
} |