This method will return FALSE if the path points to a leaf (i.e. a string,
not an array).
public getRawArray ( string $path ) : mixed | ||
$path | string | A path to the node to get |
return | mixed | Array of matching data, or FALSE on failure |
/** * When the path points to a leaf, getRawArray() should return FALSE. * * @test */ public function getRawArrayAlwaysReturnsArrayOrFalse() { $result = $this->model->getRawArray('localeDisplayNames/localeDisplayPattern/localePattern'); $this->assertEquals(false, $result); }
/** * Parses "eras" child of "dates" node and returns it's array representation. * * @param CldrModel $model CldrModel to read data from * @return array An array with localized literals for "eras" node */ protected function parseLocalizedEras(CldrModel $model) { $data = []; foreach ($model->getRawArray('dates/calendars/calendar[@type="gregorian"]/eras') as $widthType => $eras) { foreach ($eras as $eraNodeString => $eraValue) { $eraName = $model->getAttributeValue($eraNodeString, 'type'); $data[$widthType][$eraName] = $eraValue; } } return $data; }