Kint_Objects_Smarty   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 23.53%

Importance

Changes 0
Metric Value
dl 0
loc 49
ccs 4
cts 17
cp 0.2353
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
C parse() 0 41 7
1
<?php
2
3
namespace kint\parsers\objects;
4
5
use kint\inc\KintObject;
6
7
/**
8
 * Class Kint_Objects_Smarty
9
 */
10
class Kint_Objects_Smarty extends KintObject
11
{
12
  /**
13
   * @param $variable
14
   *
15
   * @return array|bool
16
   */
17 2
  public function parse(&$variable)
18
  {
19
    /** @noinspection PhpUndefinedClassInspection */
20
    if (
21 2
        !defined('\Smarty::SMARTY_VERSION') # lower than 3.x
22
        ||
23 2
        !$variable instanceof \Smarty
0 ignored issues
show
Bug introduced by
The class Smarty does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
24
    ) {
25 2
      return false;
26
    }
27
28
    /** @noinspection PhpUndefinedClassInspection */
29
    $this->name = 'object Smarty (v' . substr(Smarty::SMARTY_VERSION, 7) . ')'; # trim 'Smarty-'
30
31
    $assigned = $globalAssigns = array();
32
    /** @noinspection PhpUndefinedFieldInspection */
33
    foreach ($variable->tpl_vars as $name => $var) {
34
      $assigned[$name] = $var->value;
35
    }
36
37
    /** @noinspection PhpUndefinedClassInspection */
38
    foreach (Smarty::$global_tpl_vars as $name => $var) {
39
      if ($name === 'SCRIPT_NAME') {
40
        continue;
41
      }
42
43
      $globalAssigns[$name] = $var->value;
44
    }
45
46
    /** @noinspection PhpUndefinedMethodInspection */
47
    return array(
48
        'Assigned'          => $assigned,
49
        'Assigned globally' => $globalAssigns,
50
        'Configuration'     => array(
51
            'Compiled files stored in' => isset($variable->compile_dir)
52
                ? $variable->compile_dir
53
                : $variable->getCompileDir(),
54
        ),
55
    );
56
57
  }
58
}
59