forked from vimeo/psalm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HasExactCount.php
40 lines (32 loc) · 856 Bytes
/
HasExactCount.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Psalm\Storage\Assertion;
use Psalm\Storage\Assertion;
final class HasExactCount extends Assertion
{
/** @var positive-int */
public $count;
/** @param positive-int $count */
public function __construct(int $count)
{
$this->count = $count;
}
/** @psalm-mutation-free */
public function getNegation(): Assertion
{
return new DoesNotHaveExactCount($this->count);
}
/** @psalm-mutation-free */
public function hasEquality(): bool
{
return true;
}
public function __toString(): string
{
return '=has-exact-count-' . $this->count;
}
/** @psalm-mutation-free */
public function isNegationOf(Assertion $assertion): bool
{
return $assertion instanceof DoesNotHaveExactCount && $this->count === $assertion->count;
}
}