|
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
|
4 |
|
public static function as(StructuredQuery|string $name, ...$params): static |
|
32
|
|
|
{ |
|
33
|
4 |
|
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
|
12 |
|
public function name(StructuredQuery|string $name): static |
|
43
|
|
|
{ |
|
44
|
12 |
|
$this->use('name', $name); |
|
45
|
12 |
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Set params of the method. |
|
50
|
|
|
* |
|
51
|
|
|
* @param array[]|StructuredQuery|null $params |
|
52
|
|
|
* @return $this |
|
53
|
|
|
*/ |
|
54
|
10 |
|
public function params(array|StructuredQuery|null $params): static |
|
55
|
|
|
{ |
|
56
|
10 |
|
$this->use('params', $params); |
|
57
|
10 |
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Add a parameter to the parameters list of the method. |
|
62
|
|
|
* |
|
63
|
|
|
* @param array|StructuredQuery $param |
|
64
|
|
|
* @return $this |
|
65
|
|
|
*/ |
|
66
|
6 |
|
public function addParam(array|StructuredQuery $param): static |
|
67
|
|
|
{ |
|
68
|
6 |
|
$this->append('params', $param); |
|
69
|
6 |
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|