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

h4kuna / data-type / 36115897674

25 Sep 2026 08:59AM UTC coverage: 96.275% (-0.5%) from 96.774%
36115897674

push

github

h4kuna
build: enable checked exceptions in phpstan

DataTypeException is checked, tests are excluded from the rule.

672 of 698 relevant lines covered (96.28%)

0.96 hits per line

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

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

3
namespace h4kuna\DataType\Exceptions;
4

5
/**
6
 * Value has not expected type.
7
 */
8
final class InvalidTypeException extends DataTypeException
9
{
10
        public static function createInvalidInt(mixed $name): self
1 ✔
11
        {
12
                return self::create($name, 'int');
1 ✔
13
        }
14

15

16
        public static function createInvalidString(mixed $name): self
1 ✔
17
        {
18
                return self::create($name, 'string');
1 ✔
19
        }
20

21

22
        public static function createInvalidFloat(mixed $name): self
1 ✔
23
        {
24
                return self::create($name, 'float');
1 ✔
25
        }
26

27

28
        public static function createInvalidBool(mixed $name): self
1 ✔
29
        {
30
                return self::create($name, 'bool');
1 ✔
31
        }
32

33

34
        public static function createInvalidArray(mixed $name): self
1 ✔
35
        {
36
                return self::create($name, 'array');
1 ✔
37
        }
38

39

40
        private static function create(mixed $name, string $type): self
1 ✔
41
        {
42
                return new self(sprintf('The value "%s" is not valid %s.', self::toString($name), $type));
1 ✔
43
        }
44

45

46
        private static function toString(mixed $name): string
1 ✔
47
        {
48
                if ($name === null) {
1 ✔
49
                        return 'null';
×
50
                }
51

52
                return is_scalar($name) ? (string) $name : gettype($name);
1 ✔
53
        }
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc