Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 13, 2015
1 parent 5e19126 commit 8eb5cdd
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,24 @@ abstract class PHP_Token_Includes extends PHP_Token

public function getName()
{
if ($this->name !== null) {
return $this->name;
if ($this->name === null) {
$this->process();
}

return $this->name;
}

public function getType()
{
if ($this->type === null) {
$this->process();
}

return $this->type;
}

private function process()
{
$tokens = $this->tokenStream->tokens();

if ($tokens[$this->id+2] instanceof PHP_Token_CONSTANT_ENCAPSED_STRING) {
Expand All @@ -255,15 +269,6 @@ public function getName()
str_replace('PHP_Token_', '', get_class($tokens[$this->id]))
);
}

return $this->name;
}

public function getType()
{
$this->getName();

return $this->type;
}
}

Expand Down

0 comments on commit 8eb5cdd

Please sign in to comment.