Completed
Push — master ( 4c5edf...11034c )
by Shcherbak
02:07
created

FunctionCallPattern::__invoke()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 22
rs 8.9197
cc 4
eloc 13
nc 5
nop 1
1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommend to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
  namespace Funivan\PhpTokenizer\Pattern\Patterns;
4
5
  use Funivan\PhpTokenizer\QuerySequence\QuerySequence;
6
7
  /**
8
   *
9
   */
10
  class FunctionCallPattern implements PatternInterface {
11
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function __invoke(QuerySequence $querySequence) {
17
18
      $name = $querySequence->strict(T_STRING);
19
      $querySequence->possible(T_WHITESPACE);
20
      $arguments = $querySequence->section('(', ')');
21
22
      if (!$querySequence->isValid()) {
23
        return null;
24
      }
25
26
      $querySequence->moveToToken($name);
27
      $before = $querySequence->move(-1);
28
      if ($before->getType() === T_WHITESPACE) {
29
        $before = $querySequence->move(-1);
30
      }
31
32
      if (in_array($before->getValue(), ['::', 'function'])) {
33
        return null;
34
      }
35
36
      return $querySequence->getCollection()->extractByTokens($name, $arguments->getLast());
37
    }
38
39
  }