camel example

public function slice(int $start = 0, int $length = null)static
    {
        $str = clone $this;
        $str->string = (string) substr($this->string, $start$length ?? \PHP_INT_MAX);

        return $str;
    }

    public function snake()static
    {
        $str = $this->camel();
        $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));

        return $str;
    }

    public function splice(string $replacement, int $start = 0, int $length = null)static
    {
        $str = clone $this;
        $str->string = substr_replace($this->string, $replacement$start$length ?? \PHP_INT_MAX);

        return $str;
    }

        $properties = [
            [
                'name' => 'name',
                'prompt' => 'Please enter a name for your app',
                'description' => 'The name of your app. Used for the folder structure.',
                'default' => 'MyExampleApp',
                'validator' => self::makeRegexValidator(
                    '/^[A-Za-z]\w{3,}$/',
                    'The app name is too short (min 4 characters), contains invalid characters'
                ),
                'normaliser' => fn (string $name): string => u($name)->replace('_', ' ')->camel()->title()->toString(),
            ],
            [
                'name' => 'label',
                'prompt' => 'Please enter a label for your app',
                'description' => 'The label for your app.',
                'default' => 'My Example App',
                'validator' => self::makeRegexValidator(
                    '/[\w\s]+$/',
                    'The app label contains invalid characters. Only alphanumerics and whitespaces are allowed.'
                ),
            ],
            [
'hello_world', 1, 'hello world', ' ', '_'],
            ['hemmo wormd', 3, 'hello world', 'l', 'm'],
            ['heMMo worMd', 3, 'hello world', 'L', 'M'],
        ];
    }

    /** * @dataProvider provideCamel */
    public function testCamel(string $expectedString, string $origin)
    {
        $instance = static::createFromString($origin)->camel();

        $this->assertEquals(static::createFromString($expectedString)$instance);
    }

    public static function provideCamel()
    {
        return [
            ['', ''],
            ['xY', 'x_y'],
            ['xuYo', 'xu_yo'],
            ['symfonyIsGreat', 'symfony_is_great'],
            [
public function slice(int $start = 0, int $length = null)static
    {
        $str = clone $this;
        $str->string = (string) substr($this->string, $start$length ?? \PHP_INT_MAX);

        return $str;
    }

    public function snake()static
    {
        $str = $this->camel();
        $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));

        return $str;
    }

    public function splice(string $replacement, int $start = 0, int $length = null)static
    {
        $str = clone $this;
        $str->string = substr_replace($this->string, $replacement$start$length ?? \PHP_INT_MAX);

        return $str;
    }
public function reverse()static
    {
        $str = clone $this;
        $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));

        return $str;
    }

    public function snake()static
    {
        $str = $this->camel();
        $str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');

        return $str;
    }

    public function title(bool $allWords = false)static
    {
        $str = clone $this;

        $limit = $allWords ? -1 : 1;

        
public function reverse()static
    {
        $str = clone $this;
        $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));

        return $str;
    }

    public function snake()static
    {
        $str = $this->camel();
        $str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');

        return $str;
    }

    public function title(bool $allWords = false)static
    {
        $str = clone $this;

        $limit = $allWords ? -1 : 1;

        
private function createUser(array $claims): OidcUser
    {
        if (!\function_exists(\Symfony\Component\String\u::class)) {
            throw new \LogicException('You cannot use the "OidcUserInfoTokenHandler" since the String component is not installed. Try running "composer require symfony/string".');
        }

        foreach ($claims as $claim => $value) {
            unset($claims[$claim]);
            if ('' === $value || null === $value) {
                continue;
            }
            $claims[u($claim)->camel()->toString()] = $value;
        }

        if (isset($claims['updatedAt']) && '' !== $claims['updatedAt']) {
            $claims['updatedAt'] = (new \DateTimeImmutable())->setTimestamp($claims['updatedAt']);
        }

        if (\array_key_exists('emailVerified', $claims) && null !== $claims['emailVerified'] && '' !== $claims['emailVerified']) {
            $claims['emailVerified'] = (bool) $claims['emailVerified'];
        }

        if (\array_key_exists('phoneNumberVerified', $claims) && null !== $claims['phoneNumberVerified'] && '' !== $claims['phoneNumberVerified']) {
            
Home | Imprint | This part of the site doesn't use cookies.