Passed
Branch next (ee2197)
by Bas
02:37
created

WindowClause   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 46
ccs 18
cts 18
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A compile() 0 23 3
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\Clauses;
6
7
use LaravelFreelancerNL\FluentAQL\Expressions\Expression;
8
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
9
use phpDocumentor\Reflection\Types\ArrayKey;
10
11
class WindowClause extends Clause
12
{
13
    /**
14
     * @var array<ArrayKey, string>|object $offsets
15
     */
16
    protected array|object $offsets;
17
18
    protected null|string|QueryBuilder|Expression $rangeValue;
0 ignored issues
show
Bug introduced by
The type LaravelFreelancerNL\FluentAQL\Clauses\null was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
    protected string|null $expression;
21
22
    /**
23
     * CollectClause constructor.
24
     * @param  array<ArrayKey, string>|object $offsets
25
     */
26 2
    public function __construct(
27
        array|object $offsets,
28
        null|string|QueryBuilder|Expression $rangeValue = null
29
    ) {
30 2
        $this->offsets = $offsets;
31 2
        $this->rangeValue = $rangeValue;
32 2
    }
33
34 2
    public function compile(QueryBuilder $queryBuilder): string
35
    {
36 2
        $this->offsets = $queryBuilder->normalizeArgument(
37 2
            $this->offsets,
38 2
            ['List', 'Reference', 'Function', 'Query', 'Bind'],
39
        );
40
41 2
        if (isset($this->rangeValue)) {
42 1
            $this->rangeValue = $queryBuilder->normalizeArgument(
43 1
                $this->rangeValue,
44 1
                ['Reference', 'Function', 'Query', 'Bind'],
45
            );
46
        }
47
48 2
        $output = 'WINDOW';
49 2
        if (isset($this->rangeValue)) {
50
            /** @phpstan-ignore-next-line */
51 1
            $output .= ' ' . $this->rangeValue->compile($queryBuilder);
0 ignored issues
show
Unused Code introduced by
The call to LaravelFreelancerNL\Flue...QueryBuilder::compile() has too many arguments starting with $queryBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
            $output .= ' ' . $this->rangeValue->/** @scrutinizer ignore-call */ compile($queryBuilder);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
52 1
            $output .= ' WITH';
53
        }
54 2
        $output .= ' ' . $this->offsets->compile($queryBuilder);
55
56 2
        return $output;
57
    }
58
}
59