| 1 | <?php declare(strict_types = 1); |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | namespace App\Repositories; |
||
| 4 | |||
| 5 | use App\Entities\Example as Entity; |
||
| 6 | use App\Entities\Examples; |
||
| 7 | use WPSteak\Repositories\AbstractPost; |
||
| 8 | |||
| 9 | /** @codeCoverageIgnore */ |
||
| 10 | class Example extends AbstractPost { |
||
| 11 | |||
| 12 | public function find_one_by_post( \WP_Post $post ): ?Entity { |
||
| 13 | return new Entity( $post, $this->meta->get( (int) $post->ID, 'address', true ) ); |
||
| 14 | } |
||
| 15 | |||
| 16 | public function find_by_author_id( int $author_id, int $quantity ): Examples { |
||
| 17 | $posts = $this->get_posts( |
||
| 18 | [ |
||
| 19 | 'numberposts' => $quantity, |
||
| 20 | 'author' => $author_id, |
||
| 21 | ], |
||
|
0 ignored issues
–
show
|
|||
| 22 | ); |
||
| 23 | |||
| 24 | return new Examples( |
||
| 25 | ...array_map( |
||
| 26 | fn ( \WP_Post $post ) => new Entity( |
||
| 27 | $post, |
||
| 28 | $this->meta->get( (int) $post->ID, 'address', true ), |
||
|
0 ignored issues
–
show
|
|||
| 29 | ), |
||
| 30 | $posts, |
||
|
0 ignored issues
–
show
|
|||
| 31 | ), |
||
|
0 ignored issues
–
show
|
|||
| 32 | ); |
||
| 33 | } |
||
| 34 | |||
| 35 | } |
||
| 36 |