woocommerce-pos
/
vendor_prefixed
/
chillerlan
/
php-settings-container
/
src
/
SettingsContainerInterface.php
SettingsContainerInterface.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.5, at vendor_prefixed/chillerlan/php-settings-container/src/SettingsContainerInterface.php
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Interface SettingsContainerInterface |
| 5 | * |
| 6 | * @created 28.08.2018 |
| 7 | * @author Smiley <smiley@chillerlan.net> |
| 8 | * @copyright 2018 Smiley |
| 9 | * @license MIT |
| 10 | */ |
| 11 | declare (strict_types=1); |
| 12 | namespace WCPOS\Vendor\chillerlan\Settings; |
| 13 | |
| 14 | use JsonSerializable; |
| 15 | /** |
| 16 | * a generic container with magic getter and setter |
| 17 | */ |
| 18 | interface SettingsContainerInterface extends JsonSerializable |
| 19 | { |
| 20 | /** |
| 21 | * Retrieve the value of $property |
| 22 | * |
| 23 | * @return mixed|null |
| 24 | */ |
| 25 | public function __get(string $property); |
| 26 | /** |
| 27 | * Set $property to $value while avoiding private and non-existing properties |
| 28 | * |
| 29 | * @param string $property |
| 30 | * @param mixed $value |
| 31 | */ |
| 32 | public function __set(string $property, $value) : void; |
| 33 | /** |
| 34 | * Checks if $property is set (aka. not null), excluding private properties |
| 35 | */ |
| 36 | public function __isset(string $property) : bool; |
| 37 | /** |
| 38 | * Unsets $property while avoiding private and non-existing properties |
| 39 | */ |
| 40 | public function __unset(string $property) : void; |
| 41 | /** |
| 42 | * @see \chillerlan\Settings\SettingsContainerInterface::toJSON() |
| 43 | */ |
| 44 | public function __toString() : string; |
| 45 | /** |
| 46 | * Returns an array representation of the settings object |
| 47 | * |
| 48 | * The values will be run through the magic __get(), which may also call custom getters. |
| 49 | * |
| 50 | * @return array<string, mixed> |
| 51 | */ |
| 52 | public function toArray() : array; |
| 53 | /** |
| 54 | * Sets properties from a given iterable |
| 55 | * |
| 56 | * The values will be run through the magic __set(), which may also call custom setters. |
| 57 | * |
| 58 | * @phpstan-param array<string, mixed> $properties |
| 59 | */ |
| 60 | public function fromIterable(iterable $properties) : SettingsContainerInterface; |
| 61 | /** |
| 62 | * Returns a JSON representation of the settings object |
| 63 | * |
| 64 | * @see \json_encode() |
| 65 | * @see \chillerlan\Settings\SettingsContainerInterface::toArray() |
| 66 | * |
| 67 | * @throws \JsonException |
| 68 | */ |
| 69 | public function toJSON(?int $jsonOptions = null) : string; |
| 70 | /** |
| 71 | * Sets properties from a given JSON string |
| 72 | * |
| 73 | * @see \chillerlan\Settings\SettingsContainerInterface::fromIterable() |
| 74 | * |
| 75 | * @throws \Exception |
| 76 | * @throws \JsonException |
| 77 | */ |
| 78 | public function fromJSON(string $json) : SettingsContainerInterface; |
| 79 | } |
| 80 |