/var/www/hkosl.com/b2b2c/webadmin/libraies/paquettg/php-html-parser/src/PHPHtmlParser/Options.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace PHPHtmlParser;

/**
 * Class Options
 *
 * @package PHPHtmlParser
 * @property bool whitespaceTextNode
 * @property bool strict
 * @property bool enforceEncoding
 */
class Options
{

    
/**
     * The default options array
     *
     * @param array
     */
    
protected $defaults = [
        
'whitespaceTextNode' => true,
        
'strict'             => false,
        
'enforceEncoding'    => null,
        
'cleanupInput'       => true,
        
'removeScripts'      => true,
        
'removeStyles'       => true,
        
'preserveLineBreaks' => false,
    ];

    
/**
     * The list of all current options set.
     *
     * @param array
     */
    
protected $options = [];

    
/**
     * Sets the default options in the options array
     */
    
public function __construct()
    {
        
$this->options $this->defaults;
    }

    
/**
     * A magic get to call the get() method.
     *
     * @param string $key
     * @return mixed
     * @uses $this->get()
     */
    
public function __get($key)
    {
        return 
$this->get($key);
    }

    
/**
     * Sets a new options param to override the current option array.
     *
     * @param array $options
     * @return $this
     */
    
public function setOptions(array $options)
    {
        foreach (
$options as $key => $option) {
            
$this->options[$key] = $option;
        }

        return 
$this;
    }

    
/**
     * Gets the value associated to the key, or null if the key is not
     * found.
     *
     * @param string
     * @return mixed
     */
    
public function get($key)
    {
        if (isset(
$this->options[$key])) {
            return 
$this->options[$key];
        }

        return 
null;
    }
}