HEX
Server: Apache
System: Linux andromeda.lojoweb.com 4.18.0-372.26.1.el8_6.x86_64 #1 SMP Tue Sep 13 06:07:14 EDT 2022 x86_64
User: nakedfoamlojoweb (1056)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/cwd/wp-content/plugins/woocommerce-square/vendor/square/square/src/Models/EventData.php
<?php

declare(strict_types=1);

namespace Square\Models;

use Square\ApiHelper;
use stdClass;

class EventData implements \JsonSerializable
{
    /**
     * @var array
     */
    private $type = [];

    /**
     * @var string|null
     */
    private $id;

    /**
     * @var array
     */
    private $deleted = [];

    /**
     * @var array
     */
    private $object = [];

    /**
     * Returns Type.
     * The name of the affected object’s type.
     */
    public function getType(): ?string
    {
        if (count($this->type) == 0) {
            return null;
        }
        return $this->type['value'];
    }

    /**
     * Sets Type.
     * The name of the affected object’s type.
     *
     * @maps type
     */
    public function setType(?string $type): void
    {
        $this->type['value'] = $type;
    }

    /**
     * Unsets Type.
     * The name of the affected object’s type.
     */
    public function unsetType(): void
    {
        $this->type = [];
    }

    /**
     * Returns Id.
     * The ID of the affected object.
     */
    public function getId(): ?string
    {
        return $this->id;
    }

    /**
     * Sets Id.
     * The ID of the affected object.
     *
     * @maps id
     */
    public function setId(?string $id): void
    {
        $this->id = $id;
    }

    /**
     * Returns Deleted.
     * This is true if the affected object has been deleted; otherwise, it's absent.
     */
    public function getDeleted(): ?bool
    {
        if (count($this->deleted) == 0) {
            return null;
        }
        return $this->deleted['value'];
    }

    /**
     * Sets Deleted.
     * This is true if the affected object has been deleted; otherwise, it's absent.
     *
     * @maps deleted
     */
    public function setDeleted(?bool $deleted): void
    {
        $this->deleted['value'] = $deleted;
    }

    /**
     * Unsets Deleted.
     * This is true if the affected object has been deleted; otherwise, it's absent.
     */
    public function unsetDeleted(): void
    {
        $this->deleted = [];
    }

    /**
     * Returns Object.
     * An object containing fields and values relevant to the event. It is absent if the affected object
     * has been deleted.
     *
     * @return mixed
     */
    public function getObject()
    {
        if (count($this->object) == 0) {
            return null;
        }
        return $this->object['value'];
    }

    /**
     * Sets Object.
     * An object containing fields and values relevant to the event. It is absent if the affected object
     * has been deleted.
     *
     * @maps object
     *
     * @param mixed $object
     */
    public function setObject($object): void
    {
        $this->object['value'] = $object;
    }

    /**
     * Unsets Object.
     * An object containing fields and values relevant to the event. It is absent if the affected object
     * has been deleted.
     */
    public function unsetObject(): void
    {
        $this->object = [];
    }

    /**
     * Encode this object to JSON
     *
     * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
     *        are set. (default: false)
     *
     * @return array|stdClass
     */
    #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
    public function jsonSerialize(bool $asArrayWhenEmpty = false)
    {
        $json = [];
        if (!empty($this->type)) {
            $json['type']    = $this->type['value'];
        }
        if (isset($this->id)) {
            $json['id']      = $this->id;
        }
        if (!empty($this->deleted)) {
            $json['deleted'] = $this->deleted['value'];
        }
        if (!empty($this->object)) {
            $json['object']  = ApiHelper::decodeJson($this->object['value'], 'object');
        }
        $json = array_filter($json, function ($val) {
            return $val !== null;
        });

        return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
    }
}