<commit_before><?php

namespace Lstr\Sprintf\Middleware;

class TypeCast extends AbstractInvokable
{
    /**
     * @param AbstractInvokable|null $invokable
     */
    public function __construct(AbstractInvokable $invokable = null)
    {
        parent::__construct($invokable);
    }

    /**
     * @param InvokableParams $params
     */
    protected function process(InvokableParams $params)
    {
        $name = $params->getName();
        $name_parts = explode('::', $name, 2);
        $params->setName($name_parts[0]);

        $type = $this->getType($name_parts);
        if (null !== $type) {
            $params->setOption('type', $type);
        }
    }

    /**
     * @param array $name_parts
     * @return string|null
     */
    private function getType(array $name_parts)
    {
        if (isset($name_parts[1])) {
            return $name_parts[1];
        }
    }
}<commit_msg>Simplify TypeCast middleware implementation<commit_after><?php

namespace Lstr\Sprintf\Middleware;

class TypeCast extends AbstractInvokable
{
    /**
     * @param InvokableParams $params
     */
    protected function process(InvokableParams $params)
    {
        $name = $params->getName();
        $name_parts = explode('::', $name, 2);
        $params->setName($name_parts[0]);

        if (isset($name_parts[1])) {
            $params->setOption('type', $name_parts[1]);
        }
    }
}
{'fraction_non_alphanumeric': 0.1449067431850789, 'fraction_numerical': 0.005738880918220947, 'mean_word_length': 2.4962406015037595, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5772078', 'n_tokens_mistral': 430, 'n_tokens_neox': 425, 'n_words': 78}