Add getShortName

For #106
This commit is contained in:
Barry vd. Heuvel
2014-08-26 10:48:29 +02:00
parent 6c18c3f39a
commit 4fc9c671e8
+9 -3
View File
@@ -12,11 +12,11 @@ namespace Barryvdh\LaravelIdeHelper;
class Alias class Alias
{ {
protected $alias; protected $alias;
protected $facade; protected $facade;
protected $extends = null; protected $extends = null;
protected $classType = 'class'; protected $classType = 'class';
protected $short;
protected $namespace = '__root'; protected $namespace = '__root';
protected $root = null; protected $root = null;
protected $classes = array(); protected $classes = array();
@@ -42,7 +42,6 @@ class Alias
$facade = '\\' . ltrim($facade, '\\'); $facade = '\\' . ltrim($facade, '\\');
$this->facade = $facade; $this->facade = $facade;
$this->detectRoot(); $this->detectRoot();
if ((!$this->isTrait() && $this->root)) { if ((!$this->isTrait() && $this->root)) {
@@ -55,7 +54,6 @@ class Alias
$this->detectNamespace(); $this->detectNamespace();
$this->detectClassType(); $this->detectClassType();
} }
/** /**
@@ -114,6 +112,12 @@ class Alias
return $this->alias; return $this->alias;
} }
/**
* Return the short name (without namespace)
*/
public function getShortName(){
return $this->short;
}
/** /**
* Get the namespace from the alias * Get the namespace from the alias
* *
@@ -145,6 +149,8 @@ class Alias
$nsParts = explode('\\', $this->alias); $nsParts = explode('\\', $this->alias);
$this->short = array_pop($nsParts); $this->short = array_pop($nsParts);
$this->namespace = implode('\\', $nsParts); $this->namespace = implode('\\', $nsParts);
}else{
$this->short = $this->alias;
} }
} }