1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sanderdekroon\Parlant; |
4
|
|
|
|
5
|
|
|
use Sanderdekroon\Parlant\Builder\PosttypeBuilder; |
6
|
|
|
use Sanderdekroon\Parlant\Builder\BuilderInterface; |
7
|
|
|
|
8
|
|
|
class Posttype |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* The PosttypeBuilder of the current query. |
12
|
|
|
* @var PosttypeBuilder |
13
|
|
|
*/ |
14
|
|
|
protected static $builder; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Set the post type in the newly created builder and return the builder. |
18
|
|
|
* Since this is the start of a new query, a new instance of the |
19
|
|
|
* PosttypeBuilder is created and set as a static property. |
20
|
|
|
* @param string $type |
21
|
|
|
* @return PosttypeBuilder |
22
|
|
|
*/ |
23
|
35 |
|
public static function type($type) |
24
|
|
|
{ |
25
|
35 |
|
return (new self())->builder()->type($type); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Return posts of any post type. |
30
|
|
|
* @return PosttypeBuilder |
31
|
|
|
*/ |
32
|
13 |
|
public static function any() |
33
|
|
|
{ |
34
|
13 |
|
return self::type('any'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Find a post by it's id. |
39
|
|
|
* @param int $postId |
40
|
|
|
* @return WP_Post |
|
|
|
|
41
|
|
|
*/ |
42
|
1 |
|
public static function find($postId) |
43
|
|
|
{ |
44
|
1 |
|
return self::any()->where('p', (int)$postId)->first(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Shortcut for returning all published posts (depending on configuration) within a posttype. |
49
|
|
|
* @param string $posttype |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
2 |
|
public static function all($posttype) |
53
|
|
|
{ |
54
|
2 |
|
return self::type($posttype)->all(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Create a new instance of the builder, set it as static property and return it. |
59
|
|
|
* This makes sure that a new builder is created when a new query is created. |
60
|
|
|
* @return PosttypeBuilder |
61
|
|
|
*/ |
62
|
35 |
|
private function builder() |
63
|
|
|
{ |
64
|
35 |
|
self::$builder = new PosttypeBuilder; |
65
|
35 |
|
return self::$builder; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Direct every call to the PosttypeBuilder class. It uses the static property |
70
|
|
|
* so that any previous query argument is preserved and applied at the end. |
71
|
|
|
* @param string $method |
72
|
|
|
* @param array $paramaters |
73
|
|
|
* @return mixed |
74
|
|
|
*/ |
75
|
|
|
public function __call($method, $paramaters) |
76
|
|
|
{ |
77
|
|
|
if (method_exists($this, $method)) { |
78
|
|
|
return $this->$method(...$paramaters); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return self::$builder->$method(...$paramaters); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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