From 4fc9c671e8596ab2ae0f275d0feb8db4d4ff70f4 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 26 Aug 2014 10:48:29 +0200 Subject: [PATCH] Add getShortName For #106 --- src/Alias.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Alias.php b/src/Alias.php index a2a4703..82edd82 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -12,11 +12,11 @@ namespace Barryvdh\LaravelIdeHelper; class Alias { - protected $alias; protected $facade; protected $extends = null; protected $classType = 'class'; + protected $short; protected $namespace = '__root'; protected $root = null; protected $classes = array(); @@ -42,7 +42,6 @@ class Alias $facade = '\\' . ltrim($facade, '\\'); $this->facade = $facade; - $this->detectRoot(); if ((!$this->isTrait() && $this->root)) { @@ -55,7 +54,6 @@ class Alias $this->detectNamespace(); $this->detectClassType(); - } /** @@ -114,6 +112,12 @@ class Alias return $this->alias; } + /** + * Return the short name (without namespace) + */ + public function getShortName(){ + return $this->short; + } /** * Get the namespace from the alias * @@ -145,6 +149,8 @@ class Alias $nsParts = explode('\\', $this->alias); $this->short = array_pop($nsParts); $this->namespace = implode('\\', $nsParts); + }else{ + $this->short = $this->alias; } }