/** * Checks each line of the given value with the given validators * @param string $value * @return bool */ function Check($value) { $success = true; $strings = System\String::SplitLines($value); foreach ($strings as $string) { $success = parent::Check($string); if (!$success) { break; } } //The value is temporarily set to the substrings //when calling the parent check function above, //so we have to store it here, not before the loop: $this->SetValue($value); return $success; }
/** * Fetches the lines of a text and serializes them to an array of key value pairs * @param string $text The text representation of the array * @return array Returns the array representation as associative array */ function LinesToArray($text) { $result = array(); $lines = String::SplitLines($text); foreach ($lines as $line) { $line = trim($line); if (!$line) { continue; } $pos = strpos($line, $this->separator); $key = $line; $value = ''; if ($pos !== false) { $key = substr($line, 0, $pos); $value = substr($line, $pos + strlen($this->separator)); } $result[trim($key)] = trim($value); } return $result; }