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.

OperatorCondition::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Copyright (c) 2016, HelloFresh GmbH.
4
 * All rights reserved.
5
 *
6
 * This source code is licensed under the MIT license found in the
7
 * LICENSE file in the root directory of this source tree.
8
 */
9
10
namespace HelloFresh\FeatureToggle;
11
12
use HelloFresh\FeatureToggle\Operator\OperatorInterface;
13
14
/**
15
 * A condition based on the name of the value from the context and an operator.
16
 */
17
class OperatorCondition implements ConditionInterface
18
{
19
    /** @var string */
20
    private $key;
21
22
    /** @var OperatorInterface */
23
    private $operator;
24
25
    /**
26
     * @param string $key Name of the value
27
     * @param OperatorInterface $operator Operator to run
28
     */
29 8
    public function __construct($key, OperatorInterface $operator)
30
    {
31 8
        $this->key = $key;
32 8
        $this->operator = $operator;
33 8
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 5
    public function holdsFor(Context $context)
39
    {
40 5
        if (!$context->containsKey($this->key)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $context->containsKey($this->key) of type boolean|null is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
41 1
            return false;
42
        }
43 4
        $argument = $context->get($this->key);
44
45 4
        return $this->operator->appliesTo($argument);
46
    }
47
48
    /**
49
     * @return string
50
     */
51 2
    public function getKey()
52
    {
53 2
        return $this->key;
54
    }
55
56
    /**
57
     * @return OperatorInterface
58
     */
59 2
    public function getOperator()
60
    {
61 2
        return $this->operator;
62
    }
63
}