pluralize example


    public function testSingularize(string $plural$singular)
    {
        $this->assertSame(\is_array($singular) ? $singular : [$singular](new EnglishInflector())->singularize($plural));
    }

    /** * @dataProvider pluralizeProvider */
    public function testPluralize(string $singular$plural)
    {
        $this->assertSame(\is_array($plural) ? $plural : [$plural](new EnglishInflector())->pluralize($singular));
    }

    public function testPluralizeEmptyString()
    {
        $plural = (new EnglishInflector())->pluralize('');
        $this->assertSame(['']$plural);
    }

    public function testSingularizeEmptyString()
    {
        $singular = (new EnglishInflector())->singularize('');
        

        $this->assertSame([$singular](new FrenchInflector())->singularize($plural));
        // test casing: if the first letter was uppercase, it should remain so         $this->assertSame([ucfirst($singular)](new FrenchInflector())->singularize(ucfirst($plural)));
    }

    /** * @dataProvider pluralizeProvider */
    public function testPluralize(string $singular, string $plural)
    {
        $this->assertSame([$plural](new FrenchInflector())->pluralize($singular));
        // test casing: if the first letter was uppercase, it should remain so         $this->assertSame([ucfirst($plural)](new FrenchInflector())->pluralize(ucfirst($singular)));
    }
}


        $propName = $association->getPropertyName();
        if (mb_substr($propName, -1) === 's' || \in_array($propName, self::PLURAL_EXCEPTIONS, true)) {
            return [];
        }

        $ref = $this->getShortClassName($this->registry->get($association->getReferenceDefinition()->getClass()));
        $def = $this->getShortClassName($definition);

        $ref = str_replace($def, '', $ref);
        $refPlural = (new EnglishInflector())->pluralize($ref)[0];

        if (mb_stripos($propName$refPlural) === mb_strlen($propName) - mb_strlen($refPlural)) {
            return [];
        }

        return [
            $definition->getClass() => [
                sprintf(
                    'Association %s.%s does not end with a \'s\'.',
                    $definition->getEntityName(),
                    $association->getPropertyName()
                ),
Home | Imprint | This part of the site doesn't use cookies.