str_starts_with

Supported Versions: PHP 8
Checks if a string starts with a given substring
<?php str_starts_with(string $haystack, string $needle): bool
<?php     {

        return Targeted::make(

            $this,

            fn (ObjectDescription $object): bool => str_starts_with($object->reflectionClass->getShortName(), $prefix),

            "to have prefix '{$prefix}'",

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );
<?php     {

        return Targeted::make(

            $this->original,

            fn (ObjectDescription $object): bool => ! str_starts_with($object->reflectionClass->getShortName(), $prefix),

            "not to have prefix '{$prefix}'",

            FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),

        );
<?php     {

        $name = $testSuite->name();



        if (! str_starts_with($name, self::PREFIX)) {

            return $name;

        }
<?php             throw new InvalidArgumentException('The version must start with [<] or [>].');

        }



        if (str_starts_with($version, '>=') || str_starts_with($version, '<=')) {

            $operator = substr($version, 0, 2);

            $version = substr($version, 2);

        } elseif (str_starts_with($version, '>') || str_starts_with($version, '<')) {
<?php         if (str_starts_with($version, '>=') || str_starts_with($version, '<=')) {

            $operator = substr($version, 0, 2);

            $version = substr($version, 2);

        } elseif (str_starts_with($version, '>') || str_starts_with($version, '<')) {

            $operator = $version[0];

            $version = substr($version, 1);
<?php                 $startChar = strtolower((string) preg_replace('~^([a-z]+:\\\).*$~i', '$1', __DIR__));

            }



            return str_starts_with($path, $startChar)

                ? $path

                : implode(DIRECTORY_SEPARATOR, [

                    dirname($this->filename),
<?php                 return true;

            }



            if (str_starts_with($arg, "$argument=")) {

                return true;

            }

        }
<?php     private function ensureRunner(array $arguments): array

    {

        foreach ($arguments as $value) {

            if (str_starts_with($value, '--runner')) {

                $arguments = $this->popArgument($value, $arguments);

            }

        }
<?php             public function print(string $buffer): void

            {

                $buffer = OutputFormatter::escape($buffer);

                if (str_starts_with($buffer, "\nGenerating code coverage report")) {

                    return;

                }

                if (str_starts_with($buffer, 'done [')) {
<?php                 if (str_starts_with($buffer, "\nGenerating code coverage report")) {

                    return;

                }

                if (str_starts_with($buffer, 'done [')) {

                    return;

                }
<?php                 return false;

            }



            return str_starts_with($currentTestFile, $datasetScope);

        }, ARRAY_FILTER_USE_KEY);



        $closestScopeDatasetKey = array_reduce(
<?php         $className = (new ReflectionClass($this->target))->getName();



        if (str_starts_with($className, 'P\\')) {

            $className = substr($className, 2);

        }
<?php     public static function startsWith(string $target, string $search): bool

    {

        return str_starts_with($target, $search);

    }
<?php         $relativePath = str_replace($this->projectRoot, '', $testCaseFilename);

        $relativePath = str_replace(DIRECTORY_SEPARATOR, '/', $relativePath);



        if (str_starts_with($relativePath, '/')) {

            $relativePath = substr($relativePath, 1);

        }
<?php         $dirtyFiles = array_filter(

            $dirtyFiles,

            fn (string $file): bool => str_starts_with('.'.DIRECTORY_SEPARATOR.$file, TestSuite::getInstance()->testPath)

                || str_starts_with($file, TestSuite::getInstance()->testPath)

        );