<?php

namespace ApiAi\Model;

/**
 * Class Base
 *
 * @package ApiAi\Model
 */
class Base implements \JsonSerializable
{
    /**
     * @var array
     */
    private $data;

    /**
     * Base constructor.
     *
     * @param array $data
     */
    public function __construct($data = [])
    {
        if (empty($data)) {
            throw new \InvalidArgumentException('__construct() $data must be defined');
        }

        $this->data = $data;
    }

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        return $this->data;
    }

    /**
     * @param string $name
     *
     * @return bool
     */
    public function has($name)
    {
        return isset($this->data[$name]);
    }

    /**
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    public function get($name, $default = null)
    {
        return $this->getField($name, $default);
    }

    /**
     * @param string $name
     * @param mixed $value
     */
    public function add($name, $value)
    {
        $this->data[$name] = $value;
    }

    /**
     * @param string $name
     */
    public function remove($name)
    {
        unset($this->data[$name]);
    }

    /**
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    private function getField($name, $default = null)
    {
        return $this->has($name) ? $this->data[$name] : $default;
    }

}

<?php

namespace ApiAi\Model;

/**
 * Class Base
 *
 * @package ApiAi\Model
 */
class Base implements \JsonSerializable
{
    /**
     * @var array
     */
    private $data;

    /**
     * Base constructor.
     *
     * @param array $data
     */
    public function __construct($data = [])
    {
        $this->data = $data;
    }

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        return $this->data;
    }

    /**
     * @param string $name
     *
     * @return bool
     */
    public function has($name)
    {
        return isset($this->data[$name]);
    }

    /**
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    public function get($name, $default = null)
    {
        return $this->getField($name, $default);
    }

    /**
     * @param string $name
     * @param mixed $value
     */
    public function add($name, $value)
    {
        $this->data[$name] = $value;
    }

    /**
     * @param string $name
     */
    public function remove($name)
    {
        unset($this->data[$name]);
    }

    /**
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    private function getField($name, $default = null)
    {
        return $this->has($name) ? $this->data[$name] : $default;
    }

}

Delete data check in __construct()
Delete data check in __construct()
