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

donatj / php-dnf-solver / 14372126470

10 Apr 2025 04:10AM UTC coverage: 98.347%. Remained the same
14372126470

push

github

web-flow
Merge pull request #14 from donatj/donatj-patch-1

Test in PHP 8.4

119 of 121 relevant lines covered (98.35%)

11.65 hits per line

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

100.0
/src/Types/BuiltInType.php
1
<?php
2

3
namespace donatj\PhpDnfSolver\Types;
4

5
use donatj\PhpDnfSolver\NestedDnfTypeInterface;
6
use donatj\PhpDnfSolver\SingularDnfTypeInterface;
7
use donatj\PhpDnfSolver\Traits\UnwrapTrait;
8

9
/**
10
 * Represents a "built in type" as defined by ReflectionNamedType::isBuiltin()
11
 *
12
 * This includes:
13
 * - int
14
 * - float
15
 * - string
16
 * - bool
17
 * - array
18
 * - iterable
19
 *
20
 * @see https://www.php.net/manual/en/reflectionnamedtype.isbuiltin.php
21
 */
22
class BuiltInType implements SingularDnfTypeInterface {
23

24
        use UnwrapTrait;
25

26
        /**
27
         * @param string $name The name of the built-in type
28
         */
29
        public function __construct( private readonly string $name ) {
30
        }
18✔
31

32
        public function dnf() : string {
33
                return $this->name;
16✔
34
        }
35

36
        public function getTypeName() : string {
37
                return $this->name;
13✔
38
        }
39

40
        public function isSatisfiedBy( SingularDnfTypeInterface|NestedDnfTypeInterface $value ) : bool {
41
                if($this->name === 'mixed') {
18✔
42
                        return true;
2✔
43
                }
44

45
                $value = $this->unwrap($value);
16✔
46
                if( !$value ) {
16✔
47
                        return false;
3✔
48
                }
49

50
                $them = strtolower($value->getTypeName());
13✔
51
                $me   = strtolower($this->name);
13✔
52
                if( $them === $me ) {
13✔
53
                        return true;
5✔
54
                }
55

56
                return $them === 'int' && ($me === 'float' || $me === 'string');
9✔
57
        }
58

59
        public function count() : int {
60
                return 1;
1✔
61
        }
62

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