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