• 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/AndClause.php
1
<?php
2

3
namespace donatj\PhpDnfSolver\Types;
4

5
use donatj\PhpDnfSolver\DnfTypeInterface;
6
use donatj\PhpDnfSolver\NestedDnfTypeInterface;
7
use donatj\PhpDnfSolver\SingularDnfTypeInterface;
8

9
/**
10
 * Represents an "and clause" - a set of types which must all be satisfied - e.g. "A&B&C"
11
 */
12
class AndClause implements NestedDnfTypeInterface {
13

14
        /** @var SingularDnfTypeInterface[] */
15
        private array $types;
16

17
        /**
18
         * @param \donatj\PhpDnfSolver\SingularDnfTypeInterface ...$types The list of types to be satisfied
19
         */
20
        public function __construct( SingularDnfTypeInterface...$types ) {
21
                $this->types = $types;
23✔
22
        }
23

24
        public function dnf() : string {
25
                return implode('&', array_map(
18✔
26
                        fn ( DnfTypeInterface $type ) => $type->dnf(), $this->types)
18✔
27
                );
18✔
28
        }
29

30
        public function isSatisfiedBy( SingularDnfTypeInterface|NestedDnfTypeInterface $value ) : bool {
31
                if( $value instanceof SingularDnfTypeInterface ) {
15✔
32
                        $value = new self($value);
3✔
33
                }
34

35
                foreach( $this->getTypes() as $type ) {
15✔
36
                        foreach( $value->getTypes() as $valueType ) {
15✔
37
                                if( $type->isSatisfiedBy($valueType) ) {
15✔
38
                                        continue 2;
13✔
39
                                }
40
                        }
41

42
                        return false;
13✔
43
                }
44

45
                return true;
8✔
46
        }
47

48
        public function count() : int {
49
                return count($this->types);
16✔
50
        }
51

52
        /**
53
         * @return \donatj\PhpDnfSolver\SingularDnfTypeInterface[]
54
         */
55
        public function getTypes() : array {
56
                return $this->types;
22✔
57
        }
58

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