Example #1
0
 /**
  * Find properties based on a method name.
  *
  * This overrides graph elements findProperty, in order to allow for finding the start/end properties.
  *
  * @param string $name Method name.
  * @return Property|null Property if found, otherwise null.
  */
 function findProperty($name)
 {
     //Get the property from the method name
     $property = Reflection::getProperty($name);
     if ($this->start->matches($property)) {
         return $this->start;
     }
     if ($this->end->matches($property)) {
         return $this->end;
     }
     return parent::findProperty($name);
 }
Example #2
0
 /**
  * Checks if a supplied name matches this property's name.
  *
  * @param mixed $names List of names to check.
  * @return bool
  */
 function matches($names)
 {
     //Check every argument supplied
     foreach (func_get_args() as $name) {
         //Check for any possible match
         if (0 === strcasecmp($name, $this->name) || 0 === strcasecmp($name, $this->property->getName()) || 0 === strcasecmp($name, Reflection::normalizeProperty($this->property->getName()))) {
             return true;
         }
     }
     return false;
 }
Example #3
0
 /**
  * Gets a indexed property name, after doing required string manipulations.
  *
  * @param string $property Property name.
  * @return string The searchable index name.
  * @throws Exception Thrown if the property is not indexed.
  */
 private function getSearchableProperty($property)
 {
     $property = Meta\Reflection::normalizeProperty($property);
     foreach ($this->meta->getIndexedProperties() as $p) {
         if (Meta\Reflection::normalizeProperty($p->getName()) == $property) {
             return $property;
         }
     }
     //Node properties only have indexing problems
     if ($this->meta instanceof Node) {
         throw new Exception("Property {$property} is not indexed or does not exist in {$this->meta->getName()}.");
     } else {
         throw new Exception("Property noName is either not indexed, not a start/end, or does not exist in {$this->meta->getName()}.");
     }
 }
Example #4
0
 function testGetPropertyWeirdNotation2()
 {
     $name = Reflection::getProperty("getname");
     $this->assertEquals("name", $name);
 }
Example #5
0
 /**
  * Finds property by method name.
  *
  * @param string $name
  * @return \LRezek\Arachnid\Meta\Property|null The property, or null if it's not found.
  */
 function findProperty($name)
 {
     //Get rid of get/set and get the singularized prop name
     $property = Reflection::getProperty($name);
     foreach ($this->properties as $p) {
         if ($p->matches($property)) {
             return $p;
         }
     }
     return null;
 }