/** * @dataProvider fixLetterCaseProvider() * @depends testPluralize() * @depends testSingularize() */ public function testFixLetterCase($a, $b, $pluralise) { # We disable simplification for this test to ensure that we do not split # as camel case when testing with silly capitalisation. if ($pluralise) { $this->assertSame($b, Inflector::pluralize($a, false)); } else { $this->assertSame($b, Inflector::singularize($a, false)); } }
/** * */ protected function encodeArrayToXML($data, $parent, $pretty_print = false) { $content = ''; $parent_sing = Inflector::singularize($parent); $numeric_keys = Arrays::isNumericallyKeyed($data); if ($pretty_print !== false) { $prefix = str_repeat(' ', $pretty_print); } else { $prefix = ''; } foreach ($data as $key => $value) { $key = $numeric_keys ? $parent_sing : $key; $content .= $prefix . '<' . htmlspecialchars($key) . '>'; switch (true) { case is_array($value): case is_object($value): if ($pretty_print !== false) { $content .= "\n"; } $content .= $this->encodeArrayToXML($value, $key, $pretty_print !== false ? $pretty_print + 1 : false) . $prefix; break; case is_bool($value): $content .= $value ? 'true' : 'false'; break; case is_string($value): case is_numeric($value): default: $content .= htmlspecialchars($value); break; } $content .= '</' . htmlspecialchars($key) . '>'; if ($pretty_print !== false) { $content .= "\n"; } } return $content; }