예제 #1
0
 /**
  * testPluralize_otherWords
  * @return void
  */
 public function testPluralize_otherWords()
 {
     //arrange
     $string = 'fund';
     $pluralHelper = new PluralHelper();
     //act
     $actual = $pluralHelper->pluralize($string);
     //Assert
     $this->assertSame('funds', $actual);
 }
예제 #2
0
 /**
  * Gets the alias
  *
  * @return string
  */
 public function getAlias()
 {
     //Check and see if there is another relationship with the same name
     $multipleFound = false;
     foreach ($this->getRelationships() as $relationship) {
         if ($relationship !== $this && $relationship->getRemoteTable() == $this->getRemoteTable()) {
             $multipleFound = true;
         }
     }
     $returnVar = '';
     if ($multipleFound) {
         if ($this->isPlural()) {
             $name = $this->getRemoteColumn();
             //Strip out local table
             if (stripos($name, $this->getRemoteTable()) === 0) {
                 $name = substr($name, strlen($this->getRemoteTable()));
             }
             //Strip out remote table name, with id
             if (stripos(substr($name, strlen($this->getLocalTable() . 'Id') * -1), $this->getLocalTable() . 'Id') === 0) {
                 $name = substr($name, 0, strlen($this->getLocalTable() . 'Id') * -1);
             }
         } else {
             $name = $this->getLocalColumn();
             //Strip out local table
             if (stripos($name, $this->getLocalTable()) === 0) {
                 $name = substr($name, strlen($this->getLocalTable()));
             }
             //Strip out remote table name, with id
             if (stripos(substr($name, strlen($this->getRemoteTable() . 'Id') * -1), $this->getRemoteTable() . 'Id') === 0) {
                 $name = substr($name, 0, strlen($this->getRemoteTable() . 'Id') * -1);
             }
         }
         $returnVar .= $name;
     }
     $returnVar .= $this->getRemoteShortModel();
     if ($this->isPlural()) {
         $pluralHelper = new PluralHelper();
         $returnVar = $pluralHelper->pluralize($returnVar);
     }
     return ucfirst($returnVar);
 }