@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeEquals extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_EQUALS, |
|
40 | Messages::DATE_TIME_EQUALS, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && $value->getTimestamp() === static::readValue($context); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |
@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeLessOrEquals extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_LESS_OR_EQUALS, |
|
40 | Messages::DATE_TIME_LESS_OR_EQUALS, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && $value->getTimestamp() <= static::readValue($context); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |
@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeLessThan extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_LESS_THAN, |
|
40 | Messages::DATE_TIME_LESS_THAN, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && $value->getTimestamp() < static::readValue($context); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |
@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeMoreOrEquals extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_MORE_OR_EQUALS, |
|
40 | Messages::DATE_TIME_MORE_OR_EQUALS, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && static::readValue($context) <= $value->getTimestamp(); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |
@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeMoreThan extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_MORE_THAN, |
|
40 | Messages::DATE_TIME_MORE_THAN, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && static::readValue($context) < $value->getTimestamp(); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |
@@ 30-55 (lines=26) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class DateTimeNotEquals extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param DateTimeInterface $value |
|
34 | */ |
|
35 | public function __construct(DateTimeInterface $value) |
|
36 | { |
|
37 | parent::__construct( |
|
38 | $value->getTimestamp(), |
|
39 | ErrorCodes::DATE_TIME_NOT_EQUALS, |
|
40 | Messages::DATE_TIME_NOT_EQUALS, |
|
41 | [$value->getTimestamp()] |
|
42 | ); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * @inheritdoc |
|
47 | */ |
|
48 | public static function compare($value, ContextInterface $context): bool |
|
49 | { |
|
50 | assert($value instanceof DateTimeInterface); |
|
51 | $result = $value instanceof DateTimeInterface && $value->getTimestamp() !== static::readValue($context); |
|
52 | ||
53 | return $result; |
|
54 | } |
|
55 | } |
|
56 |