Lines Matching refs:value
49 * Determines if a PHP value would require double quoting in YAML.
51 * @param string $value A PHP value
53 public static function requiresDoubleQuoting(string $value): bool
55 return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
59 * Escapes and surrounds a PHP value with double quotes.
61 * @param string $value A PHP value
63 public static function escapeWithDoubleQuotes(string $value): string
65 return sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
69 * Determines if a PHP value would require single quoting in YAML.
71 * @param string $value A PHP value
73 public static function requiresSingleQuoting(string $value): bool
75 // Determines if a PHP value is entirely composed of a value that would
77 if (\in_array(strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'])) {
81 // Determines if the PHP value contains any single characters that would
83 return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value);
87 * Escapes and surrounds a PHP value with single quotes.
89 * @param string $value A PHP value
91 public static function escapeWithSingleQuotes(string $value): string
93 return sprintf("'%s'", str_replace('\'', '\'\'', $value));