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

Yoast / whip / 13964287980

20 Mar 2025 07:43AM UTC coverage: 28.713% (-3.0%) from 31.683%
13964287980

push

github

web-flow
Merge pull request #171 from Yoast/JRF/tests-fix-broken-covers-tags

Tests: fix broken `@covers` tags

87 of 303 relevant lines covered (28.71%)

2.63 hits per line

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

90.0
/src/Configuration.php
1
<?php
2

3
namespace Yoast\WHIPv2;
4

5
use Yoast\WHIPv2\Exceptions\InvalidType;
6
use Yoast\WHIPv2\Interfaces\Requirement;
7

8
/**
9
 * Class Configuration.
10
 */
11
class Configuration {
12

13
        /**
14
         * The configuration to use.
15
         *
16
         * @var array<string>
17
         */
18
        private $configuration;
19

20
        /**
21
         * Configuration constructor.
22
         *
23
         * @param array<string, string> $configuration The configuration to use.
24
         *
25
         * @throws InvalidType When the $configuration parameter is not of the expected type.
26
         */
27
        public function __construct( $configuration = array() ) {
3✔
28
                if ( ! \is_array( $configuration ) ) {
3✔
29
                        throw new InvalidType( 'Configuration', $configuration, 'array' );
3✔
30
                }
31

32
                $this->configuration = $configuration;
×
33
        }
34

35
        /**
36
         * Retrieves the configured version of a particular requirement.
37
         *
38
         * @param Requirement $requirement The requirement to check.
39
         *
40
         * @return string|int The version of the passed requirement that was detected as a string.
41
         *                    If the requirement does not exist, this returns int -1.
42
         */
43
        public function configuredVersion( Requirement $requirement ) {
6✔
44
                if ( ! $this->hasRequirementConfigured( $requirement ) ) {
6✔
45
                        return -1;
3✔
46
                }
47

48
                return $this->configuration[ $requirement->component() ];
3✔
49
        }
50

51
        /**
52
         * Determines whether the passed requirement is present in the configuration.
53
         *
54
         * @param Requirement $requirement The requirement to check.
55
         *
56
         * @return bool Whether or not the requirement is present in the configuration.
57
         */
58
        public function hasRequirementConfigured( Requirement $requirement ) {
3✔
59
                return \array_key_exists( $requirement->component(), $this->configuration );
3✔
60
        }
61
}
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

© 2025 Coveralls, Inc