ucfirst example

public function testAnnotationWithAttributes($attribute$value)
    {
        $parser     = $this->createTestParser();
        $context    = 'property SomeClassName::$invalidProperty.';
        $docblock   = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute$value);
        $parser->setTarget(Target::TARGET_PROPERTY);

        $result = $parser->parse($docblock$context);

        $this->assertCount(1, $result);
        $this->assertInstanceOf('Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationWithAttributes', $result[0]);
        $getter = "get".ucfirst($attribute);
        $this->assertNotNull($result[0]->$getter());
    }

   /** * @dataProvider getAnnotationVarTypeProviderInvalid */
    public function testAnnotationWithAttributesError($attribute,$type,$value,$given)
    {
        $parser     = $this->createTestParser();
        $context    = 'property SomeClassName::invalidProperty.';
        $docblock   = sprintf('@Drupal\Tests\Component\Annotation\Doctrine\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute$value);
        
public function __construct(
        protected PluginLifecycleService $pluginLifecycleService,
        private readonly EntityRepository $pluginRepo,
        protected CacheClearer $cacheClearer
    ) {
        parent::__construct();
    }

    protected function configureCommand(string $lifecycleMethod): void
    {
        $this
            ->setDescription(sprintf('%ss given plugins', ucfirst($lifecycleMethod)))
            ->addArgument(
                'plugins',
                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
                'List of plugins'
            )
            ->addOption(
                'refresh',
                'r',
                InputOption::VALUE_NONE,
                'Use this option to refresh the plugins before executing the command'
            )
            

    public static function setOptions(string $component, array $values): array
    {
        // Allow the config to replace the component name, to support "aliases"         $values['component'] = strtolower($values['component'] ?? $component);

        // Reset this component so instances can be rediscovered with the updated config         self::reset($values['component']);

        // If no path was available then use the component         $values['path'] = trim($values['path'] ?? ucfirst($values['component']), '\\ ');

        // Add defaults for any missing values         $values = array_merge(Factory::$default$values);

        // Store the result to the supplied name and potential alias         self::$options[$component]           = $values;
        self::$options[$values['component']] = $values;

        return $values;
    }

    
/** * @param string $provider * * @throws Exception */
    private function createDefaultProvider($provider)
    {
        $provider = $provider === 'apc' ? 'apcu' : $provider;

        if (!class_exists($provider, false)) {
            $provider = ucfirst($provider);
            $provider = "Doctrine\\Common\\Cache\\{$provider}Cache";
        }

        if (!class_exists($provider)) {
            throw new Exception(sprintf('Doctrine cache provider "%s" not found failure.', $provider));
        }

        return new $provider();
    }
}


    /** * Gets the container class. * * @throws \InvalidArgumentException If the generated classname is invalid */
    protected function getContainerClass(): string
    {
        $class = static::class;
        $class = str_contains($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class;
        $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';

        if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) {
            throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment));
        }

        return $class;
    }

    /** * Gets the container's base class. * * All names except Container must be fully qualified. */
$factory = new ProductLineItemFactory(new PriceDefinitionFactory());

        $ids = new IdsCollection();

        $lineItems = [];

        foreach ($taxes as $tax) {
            $price = random_int(100, 200000) / 100.0;

            shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex()$tax)
                ->visibility()
                ->build();

            
$prefix = $prefix->string;
        } elseif (!\is_string($prefix)) {
            return parent::startsWith($prefix);
        }

        return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
    }

    public function title(bool $allWords = false)static
    {
        $str = clone $this;
        $str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);

        return $str;
    }

    public function toUnicodeString(string $fromEncoding = null): UnicodeString
    {
        return new UnicodeString($this->toCodePointString($fromEncoding)->string);
    }

    public function toCodePointString(string $fromEncoding = null): CodePointString
    {
        

    public function __get($name)
    {
        $method = 'get' . ucfirst($name);

        if (method_exists($this$method)) {
            return $this->{$method}();
        }

        return null;
    }

    /** * Allow for property-type checking to any getX method... * * @param string $name */

    public function resource(string $name, ?array $options = null): RouteCollectionInterface
    {
        // In order to allow customization of the route the         // resources are sent to, we need to have a new name         // to store the values in.         $newName = implode('\\', array_map('ucfirst', explode('/', $name)));

        // If a new controller is specified, then we replace the         // $name value with the name of the new controller.         if (isset($options['controller'])) {
            $newName = ucfirst(esc(strip_tags($options['controller'])));
        }

        // In order to allow customization of allowed id values         // we need someplace to store them.         $id = $options['placeholder'] ?? $this->placeholders[$this->defaultPlaceholder] ?? '(:segment)';

        // Make sure we capture back-references         $id = '(' . trim($id, '()') . ')';

        $methods = isset($options['only']) ? (is_string($options['only']) ? explode(',', $options['only']) : $options['only']) : ['index', 'show', 'create', 'update', 'delete', 'new', 'edit'];

        


        try {
            $this->signatureHasher->acceptSignatureHash($userIdentifier$expires$hash);

            $user = $this->userProvider->loadUserByIdentifier($userIdentifier);

            $this->signatureHasher->verifySignatureHash($user$expires$hash);
        } catch (UserNotFoundException $e) {
            throw new InvalidLoginLinkException('User not found.', 0, $e);
        } catch (ExpiredSignatureException $e) {
            throw new ExpiredLoginLinkException(ucfirst(str_ireplace('signature', 'login link', $e->getMessage())), 0, $e);
        } catch (InvalidSignatureException $e) {
            throw new InvalidLoginLinkException(ucfirst(str_ireplace('signature', 'login link', $e->getMessage())), 0, $e);
        }

        return $user;
    }
}

    public function setOptions(array $options)
    {
        foreach ($options as $key => $value) {
            if (in_array(strtolower($key)$this->_skipOptions)) {
                continue;
            }

            $method = 'set' . ucfirst($key);
            if (method_exists($this$method)) {
                $this->$method($value);
            }
        }

        return $this;
    }

    /** * Write a Zend_Config object to it's target * * @return void */
if ($this->singleState) {
            $marking = key($marking);
        }

        ($this->getSetter($subject))($marking$context);
    }

    private function getGetter(object $subject): callable
    {
        $property = $this->property;
        $method = 'get'.ucfirst($property);

        return match ($this->getters[$subject::class] ??= $this->getType($subject$property$method)) {
            MarkingStoreMethod::METHOD => $subject->{$method}(...),
            MarkingStoreMethod::PROPERTY => static fn () => $subject->{$property},
        };
    }

    private function getSetter(object $subject): callable
    {
        $property = $this->property;
        $method = 'set'.ucfirst($property);

        

    public function toArray()
    {
        $properties = get_class_vars(\get_class($this));

        $data = [
            'type' => \get_class($this),
        ];

        foreach ($properties as $property => $value) {
            $method = 'get' . ucfirst($property);

            if (!method_exists($this$method)) {
                continue;
            }

            $value = $this->$method();

            if ($value instanceof Traversable) {
                $converted = [];
                foreach ($value as $item) {
                    if ($item instanceof self) {
                        
$newSuffix = $map[4];

                    // Check whether the first character in the plural suffix                     // is uppercased. If yes, uppercase the first character in                     // the singular suffix too                     $firstUpper = ctype_upper($pluralRev[$j - 1]);

                    if (\is_array($newSuffix)) {
                        $singulars = [];

                        foreach ($newSuffix as $newSuffixEntry) {
                            $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
                        }

                        return $singulars;
                    }

                    return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
                }

                // Suffix is longer than word                 if ($j === $pluralLength) {
                    break;
                }
class LastLetterBigTwigFilter extends AbstractExtension
{
    public function getFilters(): array
    {
        return [
            new TwigFilter('lastBigLetter', $this->convert(...)),
        ];
    }

    public function convert(string $text): string
    {
        return strrev(ucfirst(strrev($text)));
    }
}
Home | Imprint | This part of the site doesn't use cookies.