Passed
Pull Request — master (#12)
by Bas
02:32
created

normalizeDocument()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
nc 4
nop 1
dl 0
loc 16
ccs 0
cts 11
cp 0
crap 12
rs 9.9332
c 1
b 0
f 0
1
<?php
2
3
namespace LaravelFreelancerNL\FluentAQL\Traits;
4
5
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
6
7
/**
8
 * Trait hasFunctions.
9
 *
10
 * AQL Function API calls.
11
 */
12
trait NormalizesMiscellaneousFunctions
13
{
14
    protected function normalizeDocument(QueryBuilder $queryBuilder)
15
    {
16
        if ($this->parameters['id']  === null) {
17
            $this->parameters['id']  = $this->parameters['collection'];
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
            unset($this->parameters['collection']);
19
        }
20
21
        if (isset($this->parameters['collection'])) {
22
            $this->parameters['collection'] = $queryBuilder->normalizeArgument(
23
                $this->parameters['collection'],
24
                ['Collection', 'Id', 'Query', 'Bind']
25
            );
26
        }
27
        $this->parameters['id'] = $queryBuilder->normalizeArgument(
28
            $this->parameters['id'],
29
            ['Id', 'Key', 'Query', 'List', 'Bind']
30
        );
31
    }
32
}
33