<?php
/**
 * Created by PhpStorm.
 * User: robin
 * Date: 2/22/16
 * Time: 9:40 PM
 */

namespace Luticate\Utils\Dbo;


use Luticate\Utils\LuBusiness;
use Luticate\Utils\LuDbo;

class LuStringDboArray extends LuDbo
{
    /**
     * @var string[]
     */
    protected $_array;
    public function getArray()
    {
        return $this->_array;
    }
    public function setArray($value)
    {
        $this->_array = $value;
    }

    public function jsonSerialize()
    {
        return $this->_array;
    }

    public static function jsonDeserialize($json)
    {
        if (!is_array($json)) {
            LuBusiness::badInput("Invalid array value");
        }
        $dbo = new self();
        $array = [];
        foreach ($json as $data) {
            $array[] = LuStringDbo::jsonDeserialize($data)->getString();
        }
        $dbo->setArray($array);
        return $dbo;
    }

    public static function generateSample()
    {
        return [
            LuStringDbo::generateSample(),
            LuStringDbo::generateSample()
        ];
    }

}