public function inferType($requirement) { if (DataTypes::isPrimitive($requirement)) { return $requirement; } return DataTypes::STRING; }
/** * Creates a human-readable version of the `actualType`. `subType` is taken into account. * * @param string $actualType * @param string $subType * @return string */ protected function generateHumanReadableType($actualType, $subType) { if ($actualType == DataTypes::MODEL) { if (class_exists($subType)) { $parts = explode('\\', $subType); return sprintf('object (%s)', end($parts)); } return sprintf('object (%s)', $subType); } if ($actualType == DataTypes::COLLECTION) { if (DataTypes::isPrimitive($subType)) { return sprintf('array of %ss', $subType); } if (class_exists($subType)) { $parts = explode('\\', $subType); return sprintf('array of objects (%s)', end($parts)); } return sprintf('array of objects (%s)', $subType); } return $actualType; }
/** * Convert the type. * * @param string $type The type name. * * @return string */ public function inferType($type) { if (DataTypes::isPrimitive($type)) { return $type; } elseif (DataTypes::COLLECTION === strtolower($type)) { return $type; } return DataTypes::STRING; }