/** * @param string $field * @param integer $type * @param bool|array $multiple * @param array $options * @param Builder $builder */ private function addFieldOfType($field, $type, $multiple, array $options, Builder $builder) { switch ($type) { case Field::TYPE_FAKE: $builder->fake($field, $options[0], isset($options[1]) ? $options[1] : []); break; case Field::TYPE_LINK: $builder->link($field, $options[0]); break; case Field::TYPE_RELATION: $builder->relation($field, $options[0]); break; case Field::TYPE_VALUE: $builder->value($field, $options[0]); break; case Field::TYPE_CALLBACK: $builder->callback($field, $options[0]); break; case Field::TYPE_NONE: $builder->none($field); break; case Field::TYPE_SELECT: $builder->select($field, $options[0]); break; } if (false === $multiple) { $builder->single($field); } else { $builder->multiple($field, $multiple[0], $multiple[1]); } }
/** * @param string $name * @param Annotations\FieldInterface $annot * @param Annotations\QuantityInterface $count * @param Builder $builder */ private function addField($name, Annotations\FieldInterface $annot, $count, Builder $builder) { if ($annot instanceof Annotations\Fake) { $builder->fake($name, $annot->type, $annot->args); } elseif ($annot instanceof Annotations\Link) { $builder->link($name, $annot->target); } elseif ($annot instanceof Annotations\None) { $builder->none($name); } elseif ($annot instanceof Annotations\Select) { $builder->select($name, $annot->values); } elseif ($annot instanceof Annotations\Value) { $builder->value($name, $annot->value); } elseif ($annot instanceof Annotations\Relation) { $sub = $builder->relation($name, $annot->type); $this->processSub($annot->description, $sub); } if ($count instanceof Annotations\Multiple) { $builder->multiple($name, $count->min, $count->max); } else { $builder->single($name); } }