PHP code example of alancole / gins

1. Go to this page and download the library: Download alancole/gins library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alancole / gins example snippets


$genders = new Gins\Genders();

echo "<select name='gender'>";
foreach ($genders as $gender) {
    echo "<option value='" . $gender->getValue() . "'>";
        echo $gender->getTerm();
    echo "</option>";
}
echo "</select>";

$genders = new Gins\Genders();

try {
    $gender = $genders->findOrFailByValue("m");
    print $gender->getTerm(); // "Male"
} catch (GenderNotRegistered $e) {
    print "We couldn't find that gender"
}

$genders = new Gins\Genders();

try {
    $gender = $genders->findOrFailByTerm("Male");
    print $gender->getValue(); // "m"
} catch (GenderNotRegistered $e) {
    print "We're sorry but we don't have your gender listed,
    but we've logged its term and will get it added soon.";
}

$pronoun = $gender->getPronoun();
print $pronoun->getNoun(); // "He"

$gender->setPronoun($noun);

$pronouns = new Gins\Pronouns();

foreach ($pronouns as $noun) {
    print $pro->getNoun(); # He/She
    print $noun->getSubject(); # He/She
    print $noun->getObject(); # Him/Her
    print $noun->getPossessive(); # His/Her
    print $noun->getPossessivePlural(); # His/Hers
    print $noun->getReflexive(); #Himself/Herself
}

$noun = new Gins\Pronouns\He();

$custom_gender = new My\Custom\Gender();
$custom_gender_two = new My\Custom\GenderTwo();

$custom_pronoun = new My\Custom\Pronoun();

$genders->addGender($custom_gender);
$genders->addGender($custom_gender_two);

$all_genders = new Gins\Genders([$custom_gender, $custom_gender_two]); # Another way to do it,

$pronouns->addNoun($custom_pronoun);

$all_pronouns = new Gins\Pronouns([$custom_pronoun]); # Another way to do it.