Abstract_Repository.php
3 years ago
Ad_Repository.php
3 years ago
Placement_Type.php
3 years ago
Placement_Type_Options.php
3 years ago
Abstract_Repository.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Advanced_Ads; |
| 4 | |
| 5 | /** |
| 6 | * Abstract object repository/factory to hold object instances within a request. |
| 7 | */ |
| 8 | abstract class Abstract_Repository { |
| 9 | /** |
| 10 | * Get the object from the repository. Create and add it, if it doesn't exist. |
| 11 | * |
| 12 | * @param int $id The object id to look for. |
| 13 | */ |
| 14 | abstract public static function get( int $id ); |
| 15 | |
| 16 | /** |
| 17 | * Whether the object is in the repository. |
| 18 | * |
| 19 | * @param int $id The object id to look for. |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | protected static function has( int $id ): bool { |
| 24 | return array_key_exists( $id, static::$repo ); |
| 25 | } |
| 26 | } |
| 27 |