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

ICanBoogie / ActiveRecord / 11881061236

17 Nov 2024 06:05PM UTC coverage: 86.108% (-0.02%) from 86.125%
11881061236

push

github

olvlvl
Use PHPStan 2.0

5 of 10 new or added lines in 6 files covered. (50.0%)

16 existing lines in 2 files now uncovered.

1376 of 1598 relevant lines covered (86.11%)

24.51 hits per line

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

50.0
/lib/ActiveRecord/Property/DateTimePropertySupport.php
1
<?php
2

3
namespace ICanBoogie\ActiveRecord\Property;
4

5
use ICanBoogie\DateTime;
6

7
/**
8
 * Provides support for datetime properties.
9
 */
10
class DateTimePropertySupport
11
{
12
    /**
13
     * Sets the datetime in a property.
14
     *
15
     * @param mixed $property Reference to the property to set.
16
     * @param \DateTimeInterface|string $datetime Date and time.
17
     */
18
    public static function set(&$property, $datetime): void
19
    {
20
        $property = $datetime === 'now' ? DateTime::now() : $datetime;
6✔
21
    }
22

23
    /**
24
     * Returns the {@link DateTime} instance of a property.
25
     *
26
     * @param mixed $property Reference to the property to return.
27
     */
28
    public static function get(&$property): DateTime
29
    {
30
        if ($property instanceof DateTime) {
6✔
31
            return $property;
6✔
32
        }
33

34
        // @phpstan-ignore-next-line
35
        return $property = $property === null ? DateTime::none() : new DateTime($property, 'utc');
6✔
36
    }
37

38
    /**
39
     * @param mixed $property Reference to the property to ensure.
40
     * @param \DateTimeInterface|string $datetime
41
     */
42
    public static function ensureNotEmpty(&$property, $datetime = 'now'): DateTime
43
    {
44
        if (!self::get($property)->is_empty) {
×
NEW
45
            return $property; // @phpstan-ignore return.type
×
46
        }
47

48
        self::set($property, $datetime);
×
49

NEW
50
        return $property; // @phpstan-ignore return.type
×
51
    }
52
}
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