Neos\Eel\Helper\StringHelper::startsWith PHP Метод

startsWith() публичный Метод

Examples:: String.startsWith('Hello world!', 'Hello') == true String.startsWith('My hovercraft is full of...', 'Hello') == false String.startsWith('My hovercraft is full of...', 'hovercraft', 3) == true
public startsWith ( string $string, string $search, integer $position = null ) : boolean
$string string The input string
$search string The string to search for
$position integer The position to test (defaults to the beginning of the string)
Результат boolean
    public function startsWith($string, $search, $position = null)
    {
        $position = $position !== null ? $position : 0;
        return mb_strpos($string, $search, null, 'UTF-8') === $position;
    }

Usage Example

 /**
  * @test
  * @dataProvider startsWithExamples
  */
 public function startsWithWorks($string, $search, $position, $expected)
 {
     $helper = new StringHelper();
     $result = $helper->startsWith($string, $search, $position);
     $this->assertSame($expected, $result);
 }