Example #1
0
 public function testClassShortName()
 {
     $expectations = [['Strings', "Strings"], ['\\Packaged\\Helpers\\Strings', "Strings"], [new \Packaged\Helpers\Strings(), "Strings"]];
     foreach ($expectations as $expect) {
         $this->assertEquals($expect[1], Objects::classShortname($expect[0]));
     }
 }
Example #2
0
 public static function generate($object, $append = null, $prefix = null, $moreEntropy = false)
 {
     if ($prefix === null) {
         $class = Objects::classShortname($object);
         $short = self::getUppers($class);
         $prefix = strlen($short) > 1 ? $short : substr(strtoupper($class), 0, 3);
     }
     if ($append !== null) {
         $append = self::getUppers($append);
     }
     return uniqid(Path::buildCustom(':', [$prefix, 'PHID', $append]) . ':', $moreEntropy);
 }
Example #3
0
 /**
  * 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;
 }
 /**
  * Return a class name without the namespace prefix
  *
  * @param $class
  *
  * @return string Short class name
  *
  * @deprecated
  */
 function class_shortname($class)
 {
     return \Packaged\Helpers\Objects::classShortname($class);
 }
Example #5
0
 /**
  * Retrieve the name for this endpoint
  *
  * @return string
  */
 public function getName()
 {
     return Strings::titleize(Objects::classShortname(get_called_class()));
 }
 /**
  * Assemble the segment
  *
  * @return string
  */
 public function assemble()
 {
     throw new \RuntimeException("Unsupported segment '" . get_class($this->_segment) . "' passed to the " . ucwords(Strings::humanize(Objects::classShortname(get_called_class()))));
 }