Esempio n. 1
0
 /**
  * Set the default value of a field.
  *
  * @param string $field
  * @param mixed $value
  *
  * @throws InvalidArgumentException
  * @return $this
  */
 public function defaultValue($field, $value)
 {
     Arguments::define(Boa::string(), Boa::any())->check($field, $value);
     $this->defaults = $this->defaults->insert($field, $value);
     return $this;
 }
Esempio n. 2
0
 /**
  * @return AbstractTypeConstraint
  */
 public function getValueType()
 {
     // TODO: Figure out how to make this nicer.
     return Boa::any();
 }
Esempio n. 3
0
 /**
  * Get the type annotation for a field.
  *
  * @param string $fieldName
  *
  * @return AbstractTypeConstraint
  */
 public function getFieldType($fieldName)
 {
     return Maybe::fromMaybe(Boa::any(), $this->getFieldAnnotation($fieldName, static::ANNOTATION_TYPE));
 }
Esempio n. 4
0
 /**
  * Returns a single item by iterating through the list, successively calling
  * the iterator function and passing it an accumulator value and the current
  * value from the array, and then passing the result to the next call.
  * (From Ramda).
  *
  * @param callable $function
  * @param mixed $initial
  * @param array|Traversable $foldable
  *
  * @throws InvalidArgumentException
  * @return mixed
  */
 public static function foldl(callable $function, $initial, $foldable)
 {
     Arguments::define(Boa::func(), Boa::any(), Boa::leftFoldable())->check($function, $initial, $foldable);
     return ComplexFactory::toLeftFoldable($foldable)->foldl($function, $initial);
 }