GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AndPredicate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 38
loc 38
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A __invoke() 4 4 2
A getPredicates() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * This file is part of the predicates package.
4
 *
5
 * Copyright (c) dutekvejin
6
 *
7
 * For full copyright and license information, please refer to the LICENSE file,
8
 * located at the package root folder.
9
 */
10
11
namespace Dutek\Predicate;
12
13
/**
14
 * Predicate implementation that returns true if both predicates return true.
15
 *
16
 * @package Dutek\Predicate
17
 * @author Dušan Vejin <[email protected]>
18
 */
19 View Code Duplication
final class AndPredicate implements PredicateDecorator
20
{
21
    protected $predicate1;
22
    protected $predicate2;
23
24
    /**
25
     * AndPredicate constructor.
26
     *
27
     * @param Predicate $predicate1 The first predicate to check.
28
     * @param Predicate $predicate2 The second predicate to check.
29
     */
30 5
    public function __construct(Predicate $predicate1, Predicate $predicate2)
31
    {
32 5
        $this->predicate1 = $predicate1;
33 5
        $this->predicate2 = $predicate2;
34 5
    }
35
36
    /**
37
     * Gets the two predicates being decorated as an array.
38
     *
39
     * @return array The predicates.
40
     */
41 1
    public function getPredicates() : array
42
    {
43 1
        return [$this->predicate1, $this->predicate2];
44
    }
45
46
    /**
47
     * Evaluates the predicate returning true if both predicates return true.
48
     *
49
     * @param mixed $value The input value.
50
     * @return bool true if both decorated predicates return true
51
     */
52 4
    public function __invoke($value) : bool
53
    {
54 4
        return ($this->predicate1)($value) && ($this->predicate2)($value);
55
    }
56
}
57