summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/lib/PicoFeed/Config/Config.php
blob: 2ee3718eb4a9060f5c1776658d52cb08528ce385 (plain)
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
88
89
90
91
92
93
94
<?php

namespace PicoFeed\Config;

/**
 * Config class
 *
 * @author  Frederic Guillot
 * @package picofeed
 *
 * @method  \PicoFeed\Config\Config setClientTimeout(integer $value)
 * @method  \PicoFeed\Config\Config setClientUserAgent(string $value)
 * @method  \PicoFeed\Config\Config setMaxRedirections(integer $value)
 * @method  \PicoFeed\Config\Config setMaxBodySize(integer $value)
 * @method  \PicoFeed\Config\Config setProxyHostname(string $value)
 * @method  \PicoFeed\Config\Config setProxyPort(integer $value)
 * @method  \PicoFeed\Config\Config setProxyUsername(string $value)
 * @method  \PicoFeed\Config\Config setProxyPassword(string $value)
 * @method  \PicoFeed\Config\Config setGrabberTimeout(integer $value)
 * @method  \PicoFeed\Config\Config setGrabberUserAgent(string $value)
 * @method  \PicoFeed\Config\Config setParserHashAlgo(string $value)
 * @method  \PicoFeed\Config\Config setContentFiltering(boolean $value)
 * @method  \PicoFeed\Config\Config setTimezone(string $value)
 * @method  \PicoFeed\Config\Config setFilterIframeWhitelist(array $value)
 * @method  \PicoFeed\Config\Config setFilterIntegerAttributes(array $value)
 * @method  \PicoFeed\Config\Config setFilterAttributeOverrides(array $value)
 * @method  \PicoFeed\Config\Config setFilterRequiredAttributes(array $value)
 * @method  \PicoFeed\Config\Config setFilterMediaBlacklist(array $value)
 * @method  \PicoFeed\Config\Config setFilterMediaAttributes(array $value)
 * @method  \PicoFeed\Config\Config setFilterSchemeWhitelist(array $value)
 * @method  \PicoFeed\Config\Config setFilterWhitelistedTags(array $value)
 * @method  \PicoFeed\Config\Config setFilterBlacklistedTags(array $value)
 * @method  \PicoFeed\Config\Config setFilterImageProxyUrl($value)
 * @method  \PicoFeed\Config\Config setFilterImageProxyCallback($closure)
 *
 * @method  integer    getClientTimeout()
 * @method  string     getClientUserAgent()
 * @method  integer    getMaxRedirections()
 * @method  integer    getMaxBodySize()
 * @method  string     getProxyHostname()
 * @method  integer    getProxyPort()
 * @method  string     getProxyUsername()
 * @method  string     getProxyPassword()
 * @method  integer    getGrabberTimeout()
 * @method  string     getGrabberUserAgent()
 * @method  string     getParserHashAlgo()
 * @method  boolean    getContentFiltering(bool $default_value)
 * @method  string     getTimezone()
 * @method  array      getFilterIframeWhitelist(array $default_value)
 * @method  array      getFilterIntegerAttributes(array $default_value)
 * @method  array      getFilterAttributeOverrides(array $default_value)
 * @method  array      getFilterRequiredAttributes(array $default_value)
 * @method  array      getFilterMediaBlacklist(array $default_value)
 * @method  array      getFilterMediaAttributes(array $default_value)
 * @method  array      getFilterSchemeWhitelist(array $default_value)
 * @method  array      getFilterWhitelistedTags(array $default_value)
 * @method  array      getFilterBlacklistedTags(array $default_value)
 * @method  string     getFilterImageProxyUrl()
 * @method  \Closure   getFilterImageProxyCallback()
 */
class Config
{
    /**
     * Contains all parameters
     *
     * @access private
     * @var array
     */
    private $container = array();

    /**
     * Magic method to have any kind of setters or getters
     *
     * @access public
     * @param  string   $name        Getter/Setter name
     * @param  array    $arguments   Method arguments
     * @return mixed
     */
    public function __call($name , array $arguments)
    {
        $name = strtolower($name);
        $prefix = substr($name, 0, 3);
        $parameter = substr($name, 3);

        if ($prefix === 'set' && isset($arguments[0])) {
            $this->container[$parameter] = $arguments[0];
            return $this;
        }
        else if ($prefix === 'get') {
            $default_value = isset($arguments[0]) ? $arguments[0] : null;
            return isset($this->container[$parameter]) ? $this->container[$parameter] : $default_value;
        }
    }
}