Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
42.86% |
3 / 7 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| definition | |
42.86% |
3 / 7 |
|
66.67% |
2 / 3 |
9.66 | |
0.00% |
0 / 1 |
| __call | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| set | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| append | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\template\twig; |
| 15 | |
| 16 | /** |
| 17 | * This class holds all DEFINE variables from the current page load |
| 18 | */ |
| 19 | class definition |
| 20 | { |
| 21 | /** @var array **/ |
| 22 | protected $definitions = array(); |
| 23 | |
| 24 | /** |
| 25 | * Get a DEFINE'd variable |
| 26 | * |
| 27 | * @param string $name |
| 28 | * @param array $arguments |
| 29 | * |
| 30 | * @return mixed Null if not found |
| 31 | */ |
| 32 | public function __call($name, $arguments) |
| 33 | { |
| 34 | return (isset($this->definitions[$name])) ? $this->definitions[$name] : null; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * DEFINE a variable |
| 39 | * |
| 40 | * @param string $name |
| 41 | * @param mixed $value |
| 42 | * @return \phpbb\template\twig\definition |
| 43 | */ |
| 44 | public function set($name, $value) |
| 45 | { |
| 46 | $this->definitions[$name] = $value; |
| 47 | |
| 48 | return $this; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Append to a variable |
| 53 | * |
| 54 | * @param string $name |
| 55 | * @param string $value |
| 56 | * @return \phpbb\template\twig\definition |
| 57 | */ |
| 58 | public function append($name, $value) |
| 59 | { |
| 60 | if (!isset($this->definitions[$name])) |
| 61 | { |
| 62 | $this->definitions[$name] = ''; |
| 63 | } |
| 64 | |
| 65 | $this->definitions[$name] .= $value; |
| 66 | |
| 67 | return $this; |
| 68 | } |
| 69 | } |