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

h4kuna / ares / 15350555273

30 May 2025 03:48PM UTC coverage: 87.919%. First build
15350555273

push

github

h4kuna
feat(composer): update phpstan

14 of 36 new or added lines in 13 files covered. (38.89%)

393 of 447 relevant lines covered (87.92%)

0.88 hits per line

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

78.95
/src/Tool/Strings.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Ares\Tool;
4

5
use DateTimeImmutable;
6
use DateTimeInterface;
7
use DateTimeZone;
8
use h4kuna\Ares\Exception\LogicException;
9

10
final class Strings
11
{
12

13
        public static function trimNull(?string $v): ?string
1✔
14
        {
15
                if ($v === null) {
1✔
16
                        return null;
1✔
17
                }
18

19
                $string = trim($v);
1✔
20
                if ($string === '') {
1✔
21
                        return null;
1✔
22
                }
23

24
                return $string;
1✔
25
        }
26

27
        public static function replaceSpace(string $string): string
1✔
28
        {
29
                return str_replace(' ', '', $string);
1✔
30
        }
31

32
        /**
33
         * @return ($date is null ? null : DateTimeImmutable)
34
         */
35
        public static function createDateTime(?string $date): ?DateTimeImmutable
1✔
36
        {
37
                if ($date === null) {
1✔
38
                        return null;
1✔
39
                }
40
                return new DateTimeImmutable($date, new DateTimeZone('Europe/Prague'));
1✔
41
        }
42

43
        public static function exportDate(DateTimeInterface $date): string
1✔
44
        {
45
                return $date->format($date::RFC3339);
1✔
46
        }
47

48
        public static function fromMixed(mixed $value): ?string
49
        {
NEW
50
                if (is_string($value) || $value === null) {
×
NEW
51
                        return self::trimNull($value);
×
52
                }
53

NEW
54
                throw new LogicException(sprintf('Expected string or null, got %s.', get_debug_type($value)));
×
55
        }
56

57
        public static function fromMixedStrict(mixed $value): string
58
        {
NEW
59
                return self::fromMixed($value) ?? throw new LogicException(sprintf('Expected string, got %s.', get_debug_type($value)));
×
60
        }
61

62
}
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