Completed
Push — master ( 59b3e2...6dd6b9 )
by Andrii
15:38
created

QueryBuilder   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 2
dl 0
loc 56
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A buildAuth() 0 3 1
A buildMethod() 0 15 2
A buildUri() 0 4 1
A buildHeaders() 0 4 1
A buildProtocolVersion() 0 4 1
A buildQueryParams() 0 4 1
A buildFormParams() 0 4 1
A buildBody() 0 4 1
1
<?php
2
/**
3
 * Tools to use API as ActiveRecord for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart
6
 * @package   yii2-hiart
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\rest;
12
13
use hiqdev\hiart\Query;
14
15
class QueryBuilder extends \hiqdev\hiart\AbstractQueryBuilder
16
{
17
    /**
18
     * This function is for you to provide your authentication.
19
     * @param Query $query
20
     */
21
    public function buildAuth(Query $query)
22
    {
23
    }
24
25
    public function buildMethod(Query $query)
26
    {
27
        static $defaultMethods = [
28
            'get'       => 'GET',
29
            'put'       => 'PUT',
30
            'head'      => 'HEAD',
31
            'post'      => 'GET',
32
            'search'    => 'GET',
33
            'insert'    => 'POST',
34
            'update'    => 'PUT',
35
            'delete'    => 'DELETE',
36
        ];
37
38
        return isset($defaultMethods[$query->action]) ? $defaultMethods[$query->action] : 'POST';
39
    }
40
41
    public function buildUri(Query $query)
42
    {
43
        return $query->from;
44
    }
45
46
    public function buildHeaders(Query $query)
47
    {
48
        return [];
49
    }
50
51
    public function buildProtocolVersion(Query $query)
52
    {
53
        return null;
54
    }
55
56
    public function buildQueryParams(Query $query)
57
    {
58
        return [];
59
    }
60
61
    public function buildFormParams(Query $query)
62
    {
63
        return [];
64
    }
65
66
    public function buildBody(Query $query)
67
    {
68
        return null;
69
    }
70
}
71