Neos\Flow\I18n\Cldr\CldrModel::getNodeName PHP Method

getNodeName() public static method

The internal representation of CLDR uses array keys like: 'calendar[@type="gregorian"]' This method helps to extract the node name from such keys.
public static getNodeName ( string $nodeString ) : string
$nodeString string String with node name and optional attribute(s)
return string Name of the node
    public static function getNodeName($nodeString)
    {
        $positionOfFirstAttribute = strpos($nodeString, '[@');
        if ($positionOfFirstAttribute === false) {
            return $nodeString;
        }
        return substr($nodeString, 0, $positionOfFirstAttribute);
    }

Usage Example

 /**
  * @test
  */
 public function returnsNodeNameCorrectly()
 {
     $sampleNodeString1 = 'calendar';
     $sampleNodeString2 = 'calendar[@type="gregorian"]';
     $this->assertEquals('calendar', $this->model->getNodeName($sampleNodeString1));
     $this->assertEquals('calendar', $this->model->getNodeName($sampleNodeString2));
 }