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.

JoinOptionsInterpreter::interpretJoinOptions()   C
last analyzed

Complexity

Conditions 7
Paths 9

Size

Total Lines 43
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 43
rs 6.7272
cc 7
eloc 31
nc 9
nop 2
1
<?php
2
3
namespace Pinq\Queries\Builders;
4
5
use Pinq\Expressions as O;
6
use Pinq\Queries;
7
use Pinq\Queries\Builders\Interpretations\IJoinOptionsInterpretation;
8
9
/**
10
 * Implementation of the scope expression interpreter.
11
 *
12
 * @author Elliot Levin <[email protected]>
13
 */
14
class JoinOptionsInterpreter extends ExpressionInterpreter implements IJoinOptionsInterpreter
15
{
16
    /**
17
     * @var IJoinOptionsInterpretation
18
     */
19
    protected $interpretation;
20
21
    /**
22
     * @var ISourceInterpreter
23
     */
24
    protected $sourceInterpreter;
25
26
    public function __construct(
27
            $segmentId,
28
            IJoinOptionsInterpretation $interpretation,
29
            ISourceInterpreter $sourceInterpreter,
30
            O\IEvaluationContext $evaluationContext = null
31
    ) {
32
        parent::__construct($segmentId, $evaluationContext);
33
        $this->interpretation    = $interpretation;
34
        $this->sourceInterpreter = $sourceInterpreter;
35
    }
36
37
    public function getInterpretation()
38
    {
39
        return $this->interpretation;
40
    }
41
42
    public function interpretJoinOptions(
43
            O\MethodCallExpression $expression,
44
            O\MethodCallExpression &$sourceExpression = null
45
    ) {
46
        $defaultValueKeyPair = null;
47
        while (strcasecmp($this->getMethodName($expression), 'withDefault') === 0) {
48
            if ($defaultValueKeyPair === null) {
49
                $defaultValueKeyPair =
50
                        [$this->getArgumentValueAt(0, $expression), $this->getOptionalArgumentValueAt(1, $expression)];
51
            }
52
53
            $expression = $this->getSourceMethodCall($expression);
54
        }
55
56
        switch (strtolower($this->getMethodName($expression))) {
57
            case 'on':
58
                $this->interpretation->interpretCustomJoinFilter(
59
                        $this->getFunctionAt($this->getId('filter'), 0, $expression)
60
                );
61
                $expression = $this->getSourceMethodCall($expression);
62
                break;
63
            case 'onequality':
64
                $this->interpretation->interpretEqualityJoinFilter(
65
                        $this->getFunctionAt($this->getId('outer-key'), 0, $expression),
66
                        $this->getFunctionAt($this->getId('inner-key'), 1, $expression)
67
                );
68
                $expression = $this->getSourceMethodCall($expression);
69
                break;
70
        }
71
72
        $this->sourceInterpreter->interpretSource($this->getArgumentAt(0, $expression));
73
        $sourceInterpretation =  $this->sourceInterpreter->getInterpretation();
74
        $isGroupJoin      = strcasecmp($this->getMethodName($expression), 'groupJoin') === 0;
75
        $sourceExpression = $expression;
76
77
        return $this->interpretation->interpretJoinOptions(
78
                $isGroupJoin,
79
                $sourceInterpretation,
80
                $defaultValueKeyPair !== null ? $this->getId('default-key') : null,
81
                $defaultValueKeyPair !== null ? $this->getId('default-value') : null,
82
                $defaultValueKeyPair
83
        );
84
    }
85
}
86