Passed
Branch trunk (7dc288)
by SuperNova.WS
06:07
created

ResultMessages::templateAdd()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by Gorlum 25.01.2018 8:36
4
 */
5
6
class ResultMessages implements Countable {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
  // TODO - move to separate class
8
  /**
9
   * @var array[] $resultMessages
10
   */
11
  protected $resultMessages = [];
12
13
  public function __construct() {
14
    $this->reset();
15
  }
16
17
  /**
18
   * @param array $result
19
   */
20
  public function add($message, $status = ERR_NONE) {
21
    $this->resultMessages[] = ['MESSAGE' => $message, 'STATUS' => $status];
22
  }
23
24
  /**
25
   * @return int
26
   */
27
  public function count() {
28
    return count($this->resultMessages);
29
  }
30
31
  /**
32
   * @param template $template
33
   */
34
  public function templateAdd(template $template) {
35
    foreach ($this->resultMessages as $error_message) {
36
      $template->assign_block_vars('result', $error_message);
37
    }
38
  }
39
40
  public function reset() {
41
    $this->resultMessages = [];
42
  }
43
44
}
45