1 | <?php |
||
2 | |||
3 | namespace Sanderdekroon\Parlant\Builder; |
||
4 | |||
5 | trait BuildsQueries |
||
6 | { |
||
7 | /** |
||
8 | * Get the posts by passing the bindings, configuration and building the arguments. |
||
9 | * @return mixed |
||
10 | */ |
||
11 | 28 | public function get() |
|
12 | { |
||
13 | 28 | return $this->getCompiler() |
|
14 | 28 | ->bind($this->getBindings()) |
|
15 | 28 | ->withConfiguration($this->getConfiguration()) |
|
16 | 28 | ->build(); |
|
17 | } |
||
18 | |||
19 | /** |
||
20 | * Return only the first post. |
||
21 | * @return \WP_Post |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
23 | 1 | public function first() |
|
24 | { |
||
25 | 1 | $this->setBinding('posts_per_page', 1); |
|
26 | 1 | $posts = $this->get(); |
|
27 | |||
28 | // If the developer has requested the argument list, we'll return the full array. |
||
29 | 1 | if ($this->getConfiguration()->get('return') == 'argument') { |
|
30 | 1 | return $posts; |
|
31 | } |
||
32 | |||
33 | // If it's an array, we'll assume it's one post wrapped within an array. |
||
34 | // Anything else just gets returned without modification. |
||
35 | return is_array($posts) ? reset($posts) : $posts; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Return all posts with no limit. |
||
40 | * @return mixed |
||
41 | */ |
||
42 | 6 | public function all() |
|
43 | { |
||
44 | 6 | $this->setBinding('posts_per_page', -1); |
|
45 | 6 | return $this->get(); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Count the total of found posts. |
||
50 | * @return int |
||
51 | */ |
||
52 | public function count() |
||
53 | { |
||
54 | $this->getConfiguration()->add('return', 'Sanderdekroon\Parlant\Formatter\CountFormatter'); |
||
55 | return $this->get(); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Pluck the values of the supplied column name |
||
60 | * @return array |
||
61 | */ |
||
62 | public function pluck(string $columnname) |
||
63 | { |
||
64 | if (!in_array($columnname, $this->getGrammar()->getPostProperties())) { |
||
65 | throw new \InvalidArgumentException('Invalid columnname '.$columnname); |
||
66 | } |
||
67 | |||
68 | $this->getConfiguration()->add('return', 'Sanderdekroon\Parlant\Formatter\ArrayFormatter'); |
||
69 | |||
70 | return array_map(function ($post) use ($columnname) { |
||
71 | return $post->$columnname; |
||
72 | }, $this->get()); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @todo Implement |
||
77 | */ |
||
78 | 1 | public function avg() |
|
79 | { |
||
80 | 1 | throw new \BadMethodCallException('Accessing unimplemented method.'); |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @todo Implement |
||
85 | */ |
||
86 | 1 | public function max() |
|
87 | { |
||
88 | 1 | throw new \BadMethodCallException('Accessing unimplemented method.'); |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @todo Implement |
||
93 | */ |
||
94 | 1 | public function min() |
|
95 | { |
||
96 | 1 | throw new \BadMethodCallException('Accessing unimplemented method.'); |
|
97 | } |
||
98 | |||
99 | |||
100 | protected abstract function setBinding($key, $data); |
||
101 | |||
102 | protected abstract function getGrammar(); |
||
103 | |||
104 | protected abstract function getCompiler(); |
||
105 | |||
106 | protected abstract function getBindings(); |
||
107 | |||
108 | protected abstract function getConfiguration(); |
||
109 | } |
||
110 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths