/** * @param Type $type * @return int|float|bool|string|array|object|null */ private function getValueForType(Type $type) { if ($type instanceof IntegerType) { return 0; } else { if ($type instanceof FloatType) { return 0.0; } else { if ($type instanceof BooleanType) { return false; } else { if ($type instanceof StringType) { return ''; } else { if ($type instanceof ArrayType) { return array(); } else { if ($type instanceof MultiType) { return $this->getValueForType($type->getTypes()[0]); } else { if ($type instanceof ClassType) { return (new Mockster($type->getClass(), $this->factory))->mock(); } else { return null; } } } } } } } }
public function is($value) { if (!is_array($value)) { return false; } foreach ($value as $item) { if (!$this->itemType->is($item)) { return false; } } return true; }
/** * @param ArrayType|Type $type * @param mixed $value * @return TypedValue */ private function typedItem(Type $type, $value) { return new TypedValue($value, $type->getItemType()); }
/** * @param mixed $value * @return boolean */ public function is($value) { return $this->primitive->is($value); }
private function toString(Type $type) { if ($type instanceof ClassType) { return (new \ReflectionClass($type->getClass()))->getShortName(); } else { return (string) $type; } }
/** * @param Type|NullableType $type * @return Type */ private function getInnerType(Type $type) { return $type->getType(); }
public function is($value) { return is_null($value) || $this->type->is($value); }
private function objectOfRightClass(Type $type, $object) { return $type instanceof ClassType && is_object($object) && $type->getClass() == get_class($object); }