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

h4kuna / data-type / 6169509835

13 Sep 2023 07:47AM UTC coverage: 96.603% (+0.02%) from 96.581%
6169509835

push

github

h4kuna
- update tests
- add LazyBuilder
- add Time for better DateTime::setTime()
- add Easter

95 of 95 new or added lines in 8 files covered. (100.0%)

455 of 471 relevant lines covered (96.6%)

0.97 hits per line

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

94.12
/src/Exceptions/InvalidTypeException.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\DataType\Exceptions;
4

5
final class InvalidTypeException extends DataTypeException
6
{
7

8
        public function __construct(string $name, string $type)
1✔
9
        {
10
                parent::__construct(sprintf('The value "%s" is not valid %s.', $name, $type));
1✔
11
        }
1✔
12

13

14
        public static function invalidInt(mixed $name): self
1✔
15
        {
16
                return new self(self::toString($name), 'int');
1✔
17
        }
18

19

20
        private static function toString(mixed $name): string
1✔
21
        {
22
                if ($name === null) {
1✔
23
                        return 'null';
×
24
                }
25

26
                return is_scalar($name) ? (string) $name : gettype($name);
1✔
27
        }
28

29

30
        public static function invalidString(mixed $name): self
1✔
31
        {
32
                return new self(self::toString($name), 'string');
1✔
33
        }
34

35

36
        public static function invalidFloat(mixed $name): self
1✔
37
        {
38
                return new self(self::toString($name), 'float');
1✔
39
        }
40

41

42
        public static function invalidBool(mixed $name): self
1✔
43
        {
44
                return new self(self::toString($name), 'bool');
1✔
45
        }
46

47

48
        public static function invalidArray(mixed $name): self
1✔
49
        {
50
                return new self(self::toString($name), 'array');
1✔
51
        }
52

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