• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

48 of 48 new or added lines in 2 files covered. (100.0%)

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/Tempest/Validation/src/Rules/DateTimeFormat.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Validation\Rules;
6

7
use Attribute;
8
use DateTime;
9
use DateTimeInterface;
10
use Tempest\Validation\Rule;
11

12
#[Attribute]
13
final readonly class DateTimeFormat implements Rule
14
{
15
    public const string FORMAT = 'Y-m-d H:i:s';
16

17
    public function __construct(
5✔
18
        public string $format = self::FORMAT,
19
    ) {}
5✔
20

21
    public function isValid(mixed $value): bool
3✔
22
    {
23
        $value = match ($value instanceof DateTimeInterface) {
3✔
UNCOV
24
            true => $value->format($this->format),
×
25
            default => $value,
3✔
26
        };
3✔
27

28
        if (! is_string($value) || ! $value) {
3✔
29
            return false;
2✔
30
        }
31

32
        $date = DateTime::createFromFormat($this->format, $value);
2✔
33

34
        return $date && $date->format($this->format) === $value;
2✔
35
    }
36

37
    public function message(): string
1✔
38
    {
39
        return "Value should be a valid datetime in the format {$this->format}";
1✔
40
    }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc