/** * Retrieve the table name for this DAO * * @return string */ public function getTableName() { if ($this->_tableName === null) { $class = get_called_class(); $ns = Objects::getNamespace($class); $dirs = $this->getTableNameExcludeDirs(); foreach ($dirs as $dir) { $ns = ltrim(Strings::offset($ns, $dir), '\\'); } $this->_tableName = trim(Inflector::tableize(implode('_', [Strings::stringToUnderScore($ns), Inflector::pluralize(Objects::classShortname($class))])), '_ '); $this->_tableName = str_replace('__', '_', $this->_tableName); } return $this->_tableName; }
/** * Retrieve the final part of a string, after the first instance of the * needle has been located * * @param $haystack * @param $needle * * @return string * * @deprecated */ function string_from($haystack, $needle) { return \Packaged\Helpers\Strings::offset($haystack, $needle); }
public function testStringFrom() { $this->assertEquals('Views\\Dyn', Strings::offset('X\\Y\\Z\\Com\\Views\\Dyn', 'Com\\')); $this->assertEquals('X\\Y\\Z\\Com\\Views\\Dyn', Strings::offset('X\\Y\\Z\\Com\\Views\\Dyn', 'Mi\\')); }