for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Kernel package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Kernel;
use ReflectionObject;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/7/15
trait IdentifierTrait
{
* @var ReflectionObject
private $reflection;
* @var string
private $name;
* Get class file path.
* @return string
public function getPath()
return str_replace('\\', '/', dirname($this->getReflection()->getFileName()));
}
* Get class namespace.
public function getNamespace()
return $this->getReflection()->getNamespaceName();
* Get class name (short name).
public function getName()
if (null !== $this->name) {
return $this->name;
$name = get_class($this);
$pos = strrpos($name, '\\');
return $this->name = false === $pos ? $name : substr($name, $pos + 1);
* Get class full name.
* Return namespace and class name.
public function getFullName()
$namespace = $this->getNamespace();
return (false === empty($namespace) ? $namespace.'\\' : '').$this->getName();
* Get reflection object.
* @return ReflectionObject
protected function getReflection()
if (null === $this->reflection) {
$this->reflection = new ReflectionObject($this);
return $this->reflection;