Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add italian rules #245

Open
wants to merge 1 commit into
base: 2.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Doctrine/Inflector/InflectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\Inflector\Rules\Portuguese;
use Doctrine\Inflector\Rules\Spanish;
use Doctrine\Inflector\Rules\Turkish;
use Doctrine\Inflector\Rules\Italian;

Check failure on line 13 in lib/Doctrine/Inflector/InflectorFactory.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

Use statements should be sorted alphabetically. The first wrong one is Doctrine\Inflector\Rules\Italian.
use InvalidArgumentException;

use function sprintf;
Expand Down Expand Up @@ -42,6 +43,9 @@
case Language::TURKISH:
return new Turkish\InflectorFactory();

case Language::ITALIAN:
return new Italian\InflectorFactory();

Check warning on line 47 in lib/Doctrine/Inflector/InflectorFactory.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/InflectorFactory.php#L47

Added line #L47 was not covered by tests

default:
throw new InvalidArgumentException(sprintf(
'Language "%s" is not supported.',
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/Inflector/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class Language
public const PORTUGUESE = 'portuguese';
public const SPANISH = 'spanish';
public const TURKISH = 'turkish';
public const ITALIAN = 'italian';

private function __construct()
{
Expand Down
106 changes: 106 additions & 0 deletions lib/Doctrine/Inflector/Rules/Italian/Inflectible.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

declare(strict_types=1);

namespace Doctrine\Inflector\Rules\Italian;

use Doctrine\Inflector\Rules\Pattern;
use Doctrine\Inflector\Rules\Substitution;
use Doctrine\Inflector\Rules\Transformation;
use Doctrine\Inflector\Rules\Word;

class Inflectible
{
/**
* @return Transformation[]
*/
public static function getSingular() : iterable
{
yield new Transformation(new Pattern('e$'), 'a');
yield new Transformation(new Pattern('i$'), 'o');
}

Check warning on line 21 in lib/Doctrine/Inflector/Rules/Italian/Inflectible.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Inflectible.php#L17-L21

Added lines #L17 - L21 were not covered by tests

/**
* @return Transformation[]
*/
public static function getPlural() : iterable
{
yield new Transformation(new Pattern('i?a$'), 'e');
yield new Transformation(new Pattern('i?e$'), 'i');
yield new Transformation(new Pattern('i?o$'), 'i');
}

Check warning on line 31 in lib/Doctrine/Inflector/Rules/Italian/Inflectible.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Inflectible.php#L26-L31

Added lines #L26 - L31 were not covered by tests

/**
* @return Substitution[]
*/
public static function getIrregular() : iterable
{
yield new Substitution(new Word('ala'), new Word('ali'));
yield new Substitution(new Word('amico'), new Word('amici'));
yield new Substitution(new Word('ampio'), new Word('ampli'));
yield new Substitution(new Word('arma'), new Word('armi'));
yield new Substitution(new Word('asparago'), new Word('asparagi'));
yield new Substitution(new Word('belga'), new Word('belgi'));
yield new Substitution(new Word('braccio'), new Word('braccia'));
yield new Substitution(new Word('budello'), new Word('budella'));
yield new Substitution(new Word('bue'), new Word('buoi'));
yield new Substitution(new Word('calcagno'), new Word('calcagna'));
yield new Substitution(new Word('carcere'), new Word('carceri'));
yield new Substitution(new Word('centinaio'), new Word('centinaia'));
yield new Substitution(new Word('cerchio'), new Word('cerchia'));
yield new Substitution(new Word('cervello'), new Word('cervella'));
yield new Substitution(new Word('chirurgo'), new Word('chirurgi'));
yield new Substitution(new Word('ciglio'), new Word('ciglia'));
yield new Substitution(new Word('corno'), new Word('corna'));
yield new Substitution(new Word('cuoio'), new Word('cuoia'));
yield new Substitution(new Word('dio'), new Word('dei'));
yield new Substitution(new Word('dito'), new Word('dita'));
yield new Substitution(new Word('eco'), new Word('echi'));
yield new Substitution(new Word('equivoco'), new Word('equivoci'));
yield new Substitution(new Word('farmaco'), new Word('farmaci'));
yield new Substitution(new Word('ferramento'), new Word('ferramenta'));
yield new Substitution(new Word('filamento'), new Word('filamenta'));
yield new Substitution(new Word('filo'), new Word('fila'));
yield new Substitution(new Word('fondamento'), new Word('fondamenta'));
yield new Substitution(new Word('gesto'), new Word('gesta'));
yield new Substitution(new Word('ginocchio'), new Word('ginocchia'));
yield new Substitution(new Word('greco'), new Word('greci'));
yield new Substitution(new Word('gregge'), new Word('greggi'));
yield new Substitution(new Word('grido'), new Word('grida'));
yield new Substitution(new Word('interiore'), new Word('interiora'));
yield new Substitution(new Word('labbro'), new Word('labbra'));
yield new Substitution(new Word('lenzuolo'), new Word('lenzuola'));
yield new Substitution(new Word('magico'), new Word('magici'));
yield new Substitution(new Word('maniaco'), new Word('maniaci'));
yield new Substitution(new Word('manico'), new Word('manici'));
yield new Substitution(new Word('mano'), new Word('mani'));
yield new Substitution(new Word('medico'), new Word('medici'));
yield new Substitution(new Word('membro'), new Word('membra'));
yield new Substitution(new Word('migliaio'), new Word('migliaia'));
yield new Substitution(new Word('miglio'), new Word('miglia'));
yield new Substitution(new Word('mille'), new Word('mila'));
yield new Substitution(new Word('mio'), new Word('miei'));
yield new Substitution(new Word('mosaico'), new Word('mosaici'));
yield new Substitution(new Word('muro'), new Word('mura'));
yield new Substitution(new Word('nemico'), new Word('nemici'));
yield new Substitution(new Word('orecchio'), new Word('orecchie'));
yield new Substitution(new Word('osso'), new Word('ossa'));
yield new Substitution(new Word('paio'), new Word('paia'));
yield new Substitution(new Word('porco'), new Word('porci'));
yield new Substitution(new Word('rene'), new Word('reni'));
yield new Substitution(new Word('riso'), new Word('risa'));
yield new Substitution(new Word('rosa'), new Word('rosa'));
yield new Substitution(new Word('serramento'), new Word('serramenta'));
yield new Substitution(new Word('staio'), new Word('staia'));
yield new Substitution(new Word('strido'), new Word('strida'));
yield new Substitution(new Word('strillo'), new Word('strilla'));
yield new Substitution(new Word('suo'), new Word('suoi'));
yield new Substitution(new Word('tempio'), new Word('templi'));
yield new Substitution(new Word('tuo'), new Word('tuoi'));
yield new Substitution(new Word('uomo'), new Word('uomini'));
yield new Substitution(new Word('uovo'), new Word('uova'));
yield new Substitution(new Word('urlo'), new Word('urla'));
yield new Substitution(new Word('vestigio'), new Word('vestigia'));
yield new Substitution(new Word('viola'), new Word('viola'));
}

Check warning on line 105 in lib/Doctrine/Inflector/Rules/Italian/Inflectible.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Inflectible.php#L36-L105

Added lines #L36 - L105 were not covered by tests
}
21 changes: 21 additions & 0 deletions lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Doctrine\Inflector\Rules\Italian;

use Doctrine\Inflector\GenericLanguageInflectorFactory;
use Doctrine\Inflector\Rules\Ruleset;

final class InflectorFactory extends GenericLanguageInflectorFactory
{
protected function getSingularRuleset() : Ruleset

Check failure on line 12 in lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
return Rules::getSingularRuleset();
}

Check warning on line 15 in lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php#L12-L15

Added lines #L12 - L15 were not covered by tests

protected function getPluralRuleset() : Ruleset

Check failure on line 17 in lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
return Rules::getPluralRuleset();
}

Check warning on line 20 in lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/InflectorFactory.php#L17-L20

Added lines #L17 - L20 were not covered by tests
}
31 changes: 31 additions & 0 deletions lib/Doctrine/Inflector/Rules/Italian/Rules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Doctrine\Inflector\Rules\Italian;

use Doctrine\Inflector\Rules\Patterns;
use Doctrine\Inflector\Rules\Ruleset;
use Doctrine\Inflector\Rules\Substitutions;
use Doctrine\Inflector\Rules\Transformations;

final class Rules
{
public static function getSingularRuleset() : Ruleset

Check failure on line 14 in lib/Doctrine/Inflector/Rules/Italian/Rules.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
return new Ruleset(
new Transformations(...Inflectible::getSingular()),
new Patterns(...Uninflected::getSingular()),
(new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()
);
}

Check warning on line 21 in lib/Doctrine/Inflector/Rules/Italian/Rules.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Rules.php#L14-L21

Added lines #L14 - L21 were not covered by tests

public static function getPluralRuleset() : Ruleset

Check failure on line 23 in lib/Doctrine/Inflector/Rules/Italian/Rules.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
return new Ruleset(
new Transformations(...Inflectible::getPlural()),
new Patterns(...Uninflected::getPlural()),
new Substitutions(...Inflectible::getIrregular())
);
}

Check warning on line 30 in lib/Doctrine/Inflector/Rules/Italian/Rules.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Rules.php#L23-L30

Added lines #L23 - L30 were not covered by tests
}
48 changes: 48 additions & 0 deletions lib/Doctrine/Inflector/Rules/Italian/Uninflected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Doctrine\Inflector\Rules\Italian;

use Doctrine\Inflector\Rules\Pattern;

final class Uninflected
{
/**

Check failure on line 11 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

Found multi-line doc comment with single line content, use one-line doc comment instead.
* @return Pattern[]
*/
public static function getSingular() : iterable

Check failure on line 14 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
yield from self::getDefault();
}

Check warning on line 17 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Uninflected.php#L14-L17

Added lines #L14 - L17 were not covered by tests

/**

Check failure on line 19 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

Found multi-line doc comment with single line content, use one-line doc comment instead.
* @return Pattern[]
*/
public static function getPlural() : iterable

Check failure on line 22 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

There must be no whitespace between closing parenthesis and return type colon.
{
yield from self::getDefault();
}

Check warning on line 25 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Uninflected.php#L22-L25

Added lines #L22 - L25 were not covered by tests

/**

Check failure on line 27 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

Found multi-line doc comment with single line content, use one-line doc comment instead.
* @return Pattern[]
*/
private static function getDefault() : iterable
{
yield new Pattern('alpaca');
yield new Pattern('blu');
yield new Pattern('crocevia');
yield new Pattern('foto');
yield new Pattern('fuchsia');
yield new Pattern('gnu');
yield new Pattern('gru');
yield new Pattern('iguana');
yield new Pattern('koala');
yield new Pattern('lama');
yield new Pattern('moto');
yield new Pattern('opossum');
yield new Pattern('panda');
yield new Pattern('radio');
yield new Pattern('scacciapensieri');
}

Check warning on line 47 in lib/Doctrine/Inflector/Rules/Italian/Uninflected.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Inflector/Rules/Italian/Uninflected.php#L30-L47

Added lines #L30 - L47 were not covered by tests
}