Gajus\Vlad\Translator::deriveSelectorName PHP Method

deriveSelectorName() public static method

If selector name is ends with "_id", then Id is dropped off the name.
public static deriveSelectorName ( Selector $selector ) : string
$selector Selector
return string
    public static function deriveSelectorName(\Gajus\Vlad\Selector $selector)
    {
        $path = explode('_', implode('_', array_filter($selector->getpath())));
        if (count($path) > 1 && $path[count($path) - 1] == 'id') {
            array_pop($path);
        }
        return ucwords(implode(' ', $path));
    }

Usage Example

Beispiel #1
0
 /**
  * @dataProvider deriveInputNameProvider
  */
 public function testDeriveInputName($selector, $name)
 {
     $selector = new \Gajus\Vlad\Selector($selector);
     $this->assertSame($name, \Gajus\Vlad\Translator::deriveSelectorName($selector));
 }