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

NormalizesMiscellaneousFunctions   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizeDocument() 0 16 3
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