Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
config_variable | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
set_value | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
to_string | |
0.00% |
0 / 1 |
|
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\search\backend\sphinx; |
15 | |
16 | /** |
17 | * \phpbb\search\backend\sphinx\config_variable |
18 | * Represents a single variable inside the sphinx configuration |
19 | */ |
20 | class config_variable extends config_item |
21 | { |
22 | private $value; |
23 | private $comment; |
24 | |
25 | /** |
26 | * Constructs a new variable object |
27 | * |
28 | * @param string $name Name of the variable |
29 | * @param string $value Value of the variable |
30 | * @param string $comment Optional comment after the variable in the |
31 | * config file |
32 | */ |
33 | public function __construct(string $name, string $value, string $comment = '') |
34 | { |
35 | $this->name = $name; |
36 | $this->value = $value; |
37 | $this->comment = $comment; |
38 | } |
39 | |
40 | /** |
41 | * Allows changing the variable's value |
42 | * |
43 | * @param string $value New value for this variable |
44 | */ |
45 | public function set_value(string $value): void |
46 | { |
47 | $this->value = $value; |
48 | } |
49 | |
50 | /** |
51 | * {@inheritDoc} |
52 | */ |
53 | public function to_string(): string |
54 | { |
55 | return "\t" . $this->name . ' = ' . str_replace("\n", " \\\n", $this->value) . ($this->comment ? ' ' . $this->comment : '') . "\n"; |
56 | } |
57 | } |