Application.php
1 year ago
ApplicationCollection.php
1 year ago
BaseObject.php
1 year ago
Campaign.php
1 year ago
CampaignCapping.php
1 year ago
CampaignCollection.php
1 year ago
CampaignSchedule.php
1 year ago
CampaignSchedulePressure.php
1 year ago
CampaignScheduleUrlCriterion.php
1 year ago
CampaignStats.php
1 year ago
CampaignSuccessResponse.php
1 year ago
CampaignUrlFilters.php
1 year ago
Collection.php
1 year ago
DeliveriesCreateResponse.php
1 year ago
Event.php
1 year ago
FrequentFieldValues.php
1 year ago
GeoLocation.php
1 year ago
Installation.php
1 year ago
InstallationApplication.php
1 year ago
InstallationApplicationApple.php
1 year ago
InstallationCollection.php
1 year ago
InstallationDevice.php
1 year ago
InstallationDeviceCapabilities.php
1 year ago
InstallationDeviceConfiguration.php
1 year ago
InstallationPreferences.php
1 year ago
InstallationPushToken.php
1 year ago
Notification.php
1 year ago
NotificationAlert.php
1 year ago
NotificationAlertAndroid.php
1 year ago
NotificationAlertAndroidButton.php
1 year ago
NotificationAlertIos.php
1 year ago
NotificationAlertIosAttachment.php
1 year ago
NotificationAlertIosForeground.php
1 year ago
NotificationAlertWeb.php
1 year ago
NotificationAlertWebButton.php
1 year ago
NotificationButton.php
1 year ago
NotificationButtonAction.php
1 year ago
NotificationButtonActionEvent.php
1 year ago
NotificationInApp.php
1 year ago
NotificationInAppButton.php
1 year ago
NotificationInAppMap.php
1 year ago
NotificationInAppMapPlace.php
1 year ago
NotificationPush.php
1 year ago
NotificationPushAndroid.php
1 year ago
NotificationPushIos.php
1 year ago
NotificationPushWeb.php
1 year ago
NullObject.php
1 year ago
Pagination.php
1 year ago
Segment.php
1 year ago
SegmentCollection.php
1 year ago
SuccessResponse.php
1 year ago
User.php
1 year ago
WebSdkInitOptions.php
1 year ago
NullObject.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WonderPush\Obj; |
| 4 | |
| 5 | if (count(get_included_files()) === 1) { http_response_code(403); exit(); } // Prevent direct access |
| 6 | |
| 7 | /** |
| 8 | * Null marker for {@link \WonderPush\Obj\BaseObject} fields. |
| 9 | * |
| 10 | * The singleton instance of this class marks JSON `null` fields, as opposed to fields that are not set - which are represented by PHP's `null` value. |
| 11 | * |
| 12 | * For instance when deserializing the following JSON object `{"foo": "bar", "baz": null}` into a {@link \WonderPush\Obj\BaseObject}, |
| 13 | * calling `getBar()` would return `NullObject::getInstance()`, because the field is set to the JSON null value, |
| 14 | * but calling `getQux()` would return `null`, because the field is not set. |
| 15 | */ |
| 16 | class NullObject extends BaseObject { |
| 17 | |
| 18 | private static $_instance; |
| 19 | |
| 20 | /** |
| 21 | * DO NOT CALL. |
| 22 | * @throws \LogicException |
| 23 | * @see \WonderPush\Obj\NullObject::getInstance() |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | if (self::$_instance !== null) { |
| 27 | throw new \LogicException('You should not instantiate \WonderPush\Obj\NullObject, use \WonderPush\Obj\NullObject::getInstance() instead.'); |
| 28 | } |
| 29 | parent::__construct(); |
| 30 | } |
| 31 | |
| 32 | public static function getInstance() { |
| 33 | if (self::$_instance === null) { |
| 34 | self::$_instance = new self(); |
| 35 | } |
| 36 | return self::$_instance; |
| 37 | } |
| 38 | |
| 39 | protected function buildDataFromFields() { |
| 40 | return null; |
| 41 | } |
| 42 | |
| 43 | } |
| 44 | |
| 45 | NullObject::getInstance(); // ensure creation and that calling the constructor throws |
| 46 |