Passed
Push — master ( 418178...dff5b7 )
by Aleksandar
02:11
created

MethodStatementTrait::as()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Copyright 2021 Aleksandar Panic
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace ArekX\PQL\Sql\Statement\Traits;
19
20
use ArekX\PQL\Contracts\StructuredQuery;
21
22
trait MethodStatementTrait
23
{
24
    /**
25
     * Creates new instance of this method with values set.
26
     *
27
     * @param string|StructuredQuery $name Name of the stored procedure
28
     * @param array|StructuredQuery ...$params
29
     * @return $this
30
     */
31 2
    public static function as($name, ...$params)
32
    {
33 2
        return static::create()->name($name)->params($params);
34
    }
35
36
    /**
37
     * Name of the method.
38
     *
39
     * @param string|StructuredQuery $name
40
     * @return $this
41
     */
42 4
    public function name($name)
43
    {
44 4
        $this->use('name', $name);
45 4
        return $this;
46
    }
47
48
    /**
49
     * Set params of the method.
50
     *
51
     * @param array[]|StructuredQuery[] $params
52
     * @return $this
53
     */
54 6
    public function params($params)
55
    {
56 6
        $this->use('params', $params);
57 6
        return $this;
58
    }
59
60
    /**
61
     * Add a parameter to the parameters list of the method.
62
     *
63
     * @param $param
64
     * @return $this
65
     */
66 2
    public function addParam($param)
67
    {
68 2
        $this->append('params', $param);
1 ignored issue
show
Bug introduced by
It seems like append() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

68
        $this->/** @scrutinizer ignore-call */ 
69
               append('params', $param);
Loading history...
69 2
        return $this;
70
    }
71
}