How can I be documenting parameters that are received through the func_get_args
function?
The reason is to be able to pass several parameters to the function for the same purpose!
/**
* Gets a smart text filtered and formatted of according with the property name provided
*
* @param string $code The property name to be called
*
* @return string Returns the content of property in '$code' with formatting filter as a string
* @see Skreth\Code\Text::getTexts()
* @since 0.2
*/
public static function code($code)
{
if (!is_string($code)) throw new InvalidArgumentException("Smart text is not a string");
return StringFilter::formatting(self::getTexts($code));
}
As well, it may be possible to pass several $code
:
public static function code()
{
$code = func_num_args();
$result = [];
foreach ($code as $value) {
if (!is_string($value)) throw new InvalidArgumentException("Smart text is not a string");
$result[] = StringFilter::formatting(self::getTexts($value));
}
// OU, TALVEZ (Acredito que foreach seja mais perfomático, estou certo?)...
$result = array_map(function ($value) {
if (!is_string($value)) throw new InvalidArgumentException("Smart text is not a string");
return StringFilter::formatting(self::getTexts($value));
}, $code);
return implode(' ', $result);
}
I accept good programming practice tips too: D