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

h4kuna / data-type / 10057590774

23 Jul 2024 10:53AM UTC coverage: 96.646% (-0.6%) from 97.239%
10057590774

push

github

h4kuna
add nullable

0 of 4 new or added lines in 4 files covered. (0.0%)

634 of 656 relevant lines covered (96.65%)

0.97 hits per line

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

80.0
/src/Basic/Integer.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\DataType\Basic;
4

5
use h4kuna\DataType;
6
use h4kuna\DataType\Exceptions\InvalidTypeException;
7
use Nette\StaticClass;
8

9
final class Integer
10
{
11
        use StaticClass;
12

13
        public static function nullable(mixed $value): ?int
14
        {
NEW
15
                return $value === null ? null : self::from($value);
×
16
        }
17

18

19
        public static function from(mixed $value): int
1✔
20
        {
21
                if (is_bool($value) || is_int($value) || $value === null || $value === '' || (is_numeric($value) && $value == (int) $value)) {
1✔
22
                        return (int) $value;
1✔
23
                }
24

25
                throw InvalidTypeException::invalidInt($value);
1✔
26
        }
27

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