/** * Get a list of the computed properties * * @return array An array */ public function getComputedProperties() { if (!$this->__computed_properties) { $properties = array(); foreach ($this->getMethods() as $method) { if (substr($method, 0, 11) == 'getProperty' && $method !== 'getProperty') { $property = KStringInflector::underscore(substr($method, 11)); $properties[$property] = $property; } } $this->__computed_properties = $properties; } return $this->__computed_properties; }
/** * Method to set a table object attached to the model * * @param mixed $table An object that implements ObjectInterface, ObjectIdentifier object * or valid identifier string * @throws UnexpectedValueException If the identifier is not a table identifier * @return KModelDatabase */ public function setTable($table) { if (!$table instanceof KDatabaseTableInterface) { if (is_string($table) && strpos($table, '.') === false) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('database', 'table'); $identifier['name'] = KStringInflector::pluralize(KStringInflector::underscore($table)); $identifier = $this->getIdentifier($identifier); } else { $identifier = $this->getIdentifier($table); } if ($identifier->path[1] != 'table') { throw new UnexpectedValueException('Identifier: ' . $identifier . ' is not a table identifier'); } $table = $identifier; } $this->_table = $table; return $this; }
/** * @dataProvider provideNames */ public function testCamelizeToUnderscored($classified, $separator, $split, $exploded, $camelized, $underscored) { $this->assertEquals(KStringInflector::underscore($camelized), $underscored); }