Example #1
0
 public function run() : DependencyInterface
 {
     foreach ($this->files as $file) {
         $this->parser->reset();
         foreach (token_get_all(file_get_contents($file[0])) as $token) {
             if (is_array($token)) {
                 $this->parser->tokenArray($token);
             } else {
                 $this->parser->tokenString($token);
             }
         }
         $calls = $this->parser->getCalls();
         foreach ($calls as $call => $count) {
             $call = $this->normalize->normalize($call);
             if (!array_key_exists($call, $this->flipArray)) {
                 continue;
             }
             $key = $this->flipArray[$call];
             if (isset($this->calls[$key][$call])) {
                 $this->calls[$key][$call] = $this->calls[$key][$call] + $count;
             } else {
                 $this->calls[$key][$call] = $count;
             }
         }
     }
     return $this;
 }
Example #2
0
 public function tokenString(string $token) : ParseTokenInterface
 {
     if ($token == '(') {
         if ($this->bufferStart) {
             $callName = $this->normalize->normalize($this->functionCurrent);
             if (!isset($this->calls[$callName])) {
                 $this->calls[$callName] = 1;
             } else {
                 $this->calls[$callName]++;
             }
             $this->bufferStart = false;
         }
     } elseif ($token == ')') {
         $this->bufferStart = false;
     }
     return $this;
 }