function testIsPlural()
 {
     $this->assertTrue(Inflector::isPlural('things'));
     $this->assertTrue(Inflector::isPlural('persons'));
     $this->assertTrue(Inflector::isPlural('oxs'));
     $this->assertFalse(Inflector::isPlural('ox'));
     $this->assertFalse(Inflector::isPlural('person'));
 }
Exemple #2
0
 function __call($name, $arguments)
 {
     $relationship = Model::getRelationship($this->rowClass, $name);
     if ($relationship === false && Inflector::isPlural($name)) {
         $name = Inflector::toSingular($name);
         $relationship = Model::getRelationship($this->rowClass, $name);
         if (!$relationship instanceof BelongsToRelationship) {
             $relationship = false;
         }
     }
     if ($relationship !== false) {
         return $relationship->selectModelSet($this);
     } else {
         throw new RecessException('Relationship "' . $name . '" does not exist.', get_defined_vars());
     }
 }
 function __call($name, $arguments)
 {
     if (empty($arguments)) {
         $descriptor = Model::getDescriptor($this->rowClass);
         $attachedMethod = $descriptor->getAttachedMethod($name);
         if (!$attachedMethod) {
             if (Inflector::isPlural($name)) {
                 $attachedMethod = $descriptor->getAttachedMethod(Inflector::toSingular($name));
             }
         }
         if ($attachedMethod) {
             $params = $attachedMethod->getParameters();
             if (count($params) === 0) {
                 return call_user_func(array($attachedMethod->object, $attachedMethod->method), $this);
             }
         }
     }
     throw new RecessException('Method "' . $name . '" does not exist on ModelSet nor is attached to ' . $this->rowClass . '.', get_defined_vars());
 }