Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#1045)
by Henrique
02:21
created

Subset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 27
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use function array_diff;
17
use function is_array;
18
19
/**
20
 * Validates whether the input is a subset of a given value.
21
 *
22
 * @author Henrique Moody <[email protected]>
23
 * @author Singwai Chan <[email protected]>
24
 */
25
final class Subset extends AbstractRule
26
{
27
    /**
28
     * @var array
29
     */
30
    private $superset;
31
32
    /**
33
     * Initializes the rule.
34
     *
35
     * @param array $superset
36
     */
37 1
    public function __construct(array $superset)
38
    {
39 1
        $this->superset = $superset;
40 1
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 12
    public function validate($input): bool
46
    {
47 12
        if (!is_array($input)) {
48
            return false;
49
        }
50
51 12
        return [] === array_diff($input, $this->superset);
52
    }
53
}
54