These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace League\HTMLToMarkdown; |
||
4 | |||
5 | class Configuration |
||
6 | { |
||
7 | protected $config; |
||
8 | |||
9 | /** |
||
10 | * @param array $config |
||
11 | */ |
||
12 | 87 | public function __construct(array $config = array()) |
|
13 | { |
||
14 | 87 | $this->config = $config; |
|
15 | |||
16 | 87 | $this->checkForDeprecatedOptions($config); |
|
17 | 87 | } |
|
18 | |||
19 | /** |
||
20 | * @param array $config |
||
21 | */ |
||
22 | 81 | public function merge(array $config = array()) |
|
23 | { |
||
24 | 81 | $this->checkForDeprecatedOptions($config); |
|
25 | 81 | $this->config = array_replace_recursive($this->config, $config); |
|
26 | 81 | } |
|
27 | |||
28 | /** |
||
29 | * @param array $config |
||
30 | */ |
||
31 | public function replace(array $config = array()) |
||
32 | { |
||
33 | $this->checkForDeprecatedOptions($config); |
||
34 | $this->config = $config; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param string $key |
||
39 | * @param mixed $value |
||
40 | */ |
||
41 | 6 | public function setOption($key, $value) |
|
42 | { |
||
43 | 6 | $this->checkForDeprecatedOptions(array($key => $value)); |
|
44 | 6 | $this->config[$key] = $value; |
|
45 | 6 | } |
|
46 | |||
47 | /** |
||
48 | * @param string|null $key |
||
49 | * @param mixed|null $default |
||
50 | * |
||
51 | * @return mixed|null |
||
52 | */ |
||
53 | 81 | public function getOption($key = null, $default = null) |
|
54 | { |
||
55 | 81 | if ($key === null) { |
|
56 | return $this->config; |
||
57 | } |
||
58 | |||
59 | 81 | if (!isset($this->config[$key])) { |
|
60 | 12 | return $default; |
|
61 | } |
||
62 | |||
63 | 78 | return $this->config[$key]; |
|
64 | } |
||
65 | |||
66 | 87 | private function checkForDeprecatedOptions(array $config) |
|
67 | { |
||
68 | 87 | foreach ($config as $key => $value) { |
|
69 | 81 | if ($key === 'bold_style' && $value !== '**') { |
|
70 | 3 | @trigger_error('Customizing the bold_style option is deprecated and may be removed in the next major version', E_USER_DEPRECATED); |
|
0 ignored issues
–
show
|
|||
71 | 81 | } elseif ($key === 'italic_style' && $value !== '*') { |
|
72 | 29 | @trigger_error('Customizing the italic_style option is deprecated and may be removed in the next major version', E_USER_DEPRECATED); |
|
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||
73 | 2 | } |
|
74 | 58 | } |
|
75 | 87 | } |
|
76 | } |
||
77 |
If you suppress an error, we recommend checking for the error condition explicitly: