/**
  * {@inheritdoc}
  */
 public function __construct(array $values)
 {
     if (!array_key_exists('data', $values)) {
         throw InvalidArgumentException::expectedIndex('data');
     }
     parent::__construct(['data' => new Collection($values['data'])]);
 }
예제 #2
0
 /**
  * Construct
  *
  * @param string $json JSON data
  * @param string $method Method
  * @throws InvalidArgumentException
  */
 public function __construct($json, $method)
 {
     $this->json = $json;
     if (!$this->isValidMethod($method)) {
         throw InvalidArgumentException::invalidMethod($method, self::$mapping);
     }
     $this->method = $method;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values)
 {
     if (!array_key_exists('data', $values)) {
         throw InvalidArgumentException::expectedIndex('data');
     }
     $items = [];
     foreach ($values['data'] as $series) {
         $items[] = new Series(['data' => $series]);
     }
     parent::__construct(['data' => new Collection($items)]);
 }
예제 #4
0
 /**
  * @param string $name
  * @param array $arguments
  * @throws \InvalidArgumentException
  */
 public final function __call($name, array $arguments = [])
 {
     $attributes = array_flip($this->getAttributes());
     $attribute = strtolower(substr($name, 3, 1)) . substr($name, 4);
     if (!array_key_exists($attribute, $attributes)) {
         throw InvalidArgumentException::undefinedAttribute($attribute, get_class($this));
     }
     if (!array_key_exists($attribute, $this->values)) {
         throw InvalidArgumentException::noValueForAttribute($attribute, get_class($this));
     }
     return $this->values[$attribute];
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values)
 {
     if (!array_key_exists('data', $values)) {
         throw InvalidArgumentException::expectedIndex('data');
     }
     if (!array_key_exists('links', $values)) {
         throw InvalidArgumentException::expectedIndex('links');
     }
     $items = [];
     foreach ($values['data'] as $basicEpisode) {
         $items[] = new BasicEpisode($basicEpisode);
     }
     parent::__construct(['data' => new Collection($items), 'links' => new Links($values['links'])]);
 }