Completed
Push — master ( a6cc58...1b8eb5 )
by Martijn
26s
created
SwaggerGen/Swagger/Type/Custom/ICustomType.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 interface ICustomType
14 14
 {
15 15
 
16
-    /**
17
-     * Return a list of formats recognized by this type
18
-     * @return string[]
19
-     */
20
-    public static function getFormats();
16
+	/**
17
+	 * Return a list of formats recognized by this type
18
+	 * @return string[]
19
+	 */
20
+	public static function getFormats();
21 21
 
22
-    /**
23
-     * Overwrite format names recognized by this type
24
-     * @param string[] $formats
25
-     */
26
-    public static function setFormats(array $formats);
22
+	/**
23
+	 * Overwrite format names recognized by this type
24
+	 * @param string[] $formats
25
+	 */
26
+	public static function setFormats(array $formats);
27 27
 
28 28
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Type/Custom/EmailType.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
 class EmailType extends StringType implements ICustomType
18 18
 {
19 19
 
20
-    const PATTERN = '\A[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z';
21
-
22
-    /**
23
-     * List of formats recognized by this class
24
-     * @var string[]
25
-     */
26
-    private static $formats = array('email');
27
-
28
-    /**
29
-     * Construct and set up the regular expression for this type
30
-     *
31
-     * @param AbstractObject $parent
32
-     * @param string $definition
33
-     */
34
-    public function __construct(AbstractObject $parent, $definition)
35
-    {
36
-        $this->pattern = self::PATTERN;
37
-
38
-        parent::__construct($parent, $definition);
39
-    }
40
-
41
-    /**
42
-     * Parse a type definition string, assuming it belongs to this type
43
-     *
44
-     * @param string $definition
45
-     * @throws Exception
46
-     */
47
-    protected function parseDefinition($definition)
48
-    {
49
-        $definition = self::trim($definition);
50
-
51
-        $match = array();
52
-        if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
-            throw new Exception("Unparseable email definition: '{$definition}'");
54
-        }
55
-
56
-        if (!in_array(strtolower($match[1]), self::$formats)) {
57
-            throw new Exception("Not an email: '{$definition}'");
58
-        }
59
-
60
-        $this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
-    }
62
-
63
-    /**
64
-     * Check (and optionally reformat) a default value
65
-     *
66
-     * @param string $value
67
-     * @return string
68
-     * @throws Exception
69
-     */
70
-    protected function validateDefault($value)
71
-    {
72
-        if (empty($value)) {
73
-            throw new Exception("Empty email default");
74
-        }
75
-
76
-        if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
77
-            throw new Exception("Invalid email default value: '{$value}'");
78
-        }
79
-
80
-        return $value;
81
-    }
82
-
83
-    public static function getFormats()
84
-    {
85
-        return self::$formats;
86
-    }
87
-
88
-    public static function setFormats(array $formats)
89
-    {
90
-        self::$formats = $formats;
91
-    }
20
+	const PATTERN = '\A[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z';
21
+
22
+	/**
23
+	 * List of formats recognized by this class
24
+	 * @var string[]
25
+	 */
26
+	private static $formats = array('email');
27
+
28
+	/**
29
+	 * Construct and set up the regular expression for this type
30
+	 *
31
+	 * @param AbstractObject $parent
32
+	 * @param string $definition
33
+	 */
34
+	public function __construct(AbstractObject $parent, $definition)
35
+	{
36
+		$this->pattern = self::PATTERN;
37
+
38
+		parent::__construct($parent, $definition);
39
+	}
40
+
41
+	/**
42
+	 * Parse a type definition string, assuming it belongs to this type
43
+	 *
44
+	 * @param string $definition
45
+	 * @throws Exception
46
+	 */
47
+	protected function parseDefinition($definition)
48
+	{
49
+		$definition = self::trim($definition);
50
+
51
+		$match = array();
52
+		if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
+			throw new Exception("Unparseable email definition: '{$definition}'");
54
+		}
55
+
56
+		if (!in_array(strtolower($match[1]), self::$formats)) {
57
+			throw new Exception("Not an email: '{$definition}'");
58
+		}
59
+
60
+		$this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
+	}
62
+
63
+	/**
64
+	 * Check (and optionally reformat) a default value
65
+	 *
66
+	 * @param string $value
67
+	 * @return string
68
+	 * @throws Exception
69
+	 */
70
+	protected function validateDefault($value)
71
+	{
72
+		if (empty($value)) {
73
+			throw new Exception("Empty email default");
74
+		}
75
+
76
+		if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
77
+			throw new Exception("Invalid email default value: '{$value}'");
78
+		}
79
+
80
+		return $value;
81
+	}
82
+
83
+	public static function getFormats()
84
+	{
85
+		return self::$formats;
86
+	}
87
+
88
+	public static function setFormats(array $formats)
89
+	{
90
+		self::$formats = $formats;
91
+	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Type/Custom/Ipv4Type.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
 class Ipv4Type extends StringType implements ICustomType
18 18
 {
19 19
 
20
-    const PATTERN = '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}$';
21
-
22
-    /**
23
-     * List of formats recognized by this class
24
-     * @var string[]
25
-     */
26
-    private static $formats = array('ipv4');
27
-
28
-    /**
29
-     * Construct and set up the regular expression for this type
30
-     *
31
-     * @param AbstractObject $parent
32
-     * @param string $definition
33
-     */
34
-    public function __construct(AbstractObject $parent, $definition)
35
-    {
36
-        $this->pattern = self::PATTERN;
37
-
38
-        parent::__construct($parent, $definition);
39
-    }
40
-
41
-    /**
42
-     * Parse a type definition string, assuming it belongs to this type
43
-     *
44
-     * @param string $definition
45
-     * @throws Exception
46
-     */
47
-    protected function parseDefinition($definition)
48
-    {
49
-        $definition = self::trim($definition);
50
-
51
-        $match = array();
52
-        if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
-            throw new Exception("Unparseable IPv4 definition: '{$definition}'");
54
-        }
55
-
56
-        if (!in_array(strtolower($match[1]), self::$formats)) {
57
-            throw new Exception("Not an IPv4: '{$definition}'");
58
-        }
59
-
60
-        $this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
-    }
62
-
63
-    /**
64
-     * Check (and optionally reformat) a default value
65
-     *
66
-     * @param string $value
67
-     * @return string
68
-     * @throws Exception
69
-     */
70
-    protected function validateDefault($value)
71
-    {
72
-        if (empty($value)) {
73
-            throw new Exception("Empty IPv4 default");
74
-        }
75
-
76
-        if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
77
-            throw new Exception("Invalid IPv4 default value: '{$value}'");
78
-        }
79
-
80
-        return $value;
81
-    }
82
-
83
-    public static function getFormats()
84
-    {
85
-        return self::$formats;
86
-    }
87
-
88
-    public static function setFormats(array $formats)
89
-    {
90
-        self::$formats = $formats;
91
-    }
20
+	const PATTERN = '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}$';
21
+
22
+	/**
23
+	 * List of formats recognized by this class
24
+	 * @var string[]
25
+	 */
26
+	private static $formats = array('ipv4');
27
+
28
+	/**
29
+	 * Construct and set up the regular expression for this type
30
+	 *
31
+	 * @param AbstractObject $parent
32
+	 * @param string $definition
33
+	 */
34
+	public function __construct(AbstractObject $parent, $definition)
35
+	{
36
+		$this->pattern = self::PATTERN;
37
+
38
+		parent::__construct($parent, $definition);
39
+	}
40
+
41
+	/**
42
+	 * Parse a type definition string, assuming it belongs to this type
43
+	 *
44
+	 * @param string $definition
45
+	 * @throws Exception
46
+	 */
47
+	protected function parseDefinition($definition)
48
+	{
49
+		$definition = self::trim($definition);
50
+
51
+		$match = array();
52
+		if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
+			throw new Exception("Unparseable IPv4 definition: '{$definition}'");
54
+		}
55
+
56
+		if (!in_array(strtolower($match[1]), self::$formats)) {
57
+			throw new Exception("Not an IPv4: '{$definition}'");
58
+		}
59
+
60
+		$this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
+	}
62
+
63
+	/**
64
+	 * Check (and optionally reformat) a default value
65
+	 *
66
+	 * @param string $value
67
+	 * @return string
68
+	 * @throws Exception
69
+	 */
70
+	protected function validateDefault($value)
71
+	{
72
+		if (empty($value)) {
73
+			throw new Exception("Empty IPv4 default");
74
+		}
75
+
76
+		if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
77
+			throw new Exception("Invalid IPv4 default value: '{$value}'");
78
+		}
79
+
80
+		return $value;
81
+	}
82
+
83
+	public static function getFormats()
84
+	{
85
+		return self::$formats;
86
+	}
87
+
88
+	public static function setFormats(array $formats)
89
+	{
90
+		self::$formats = $formats;
91
+	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Type/Custom/Ipv6Type.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
 class Ipv6Type extends StringType implements ICustomType
18 18
 {
19 19
 
20
-    const PATTERN = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))';
21
-
22
-    /**
23
-     * List of formats recognized by this class
24
-     * @var string[]
25
-     */
26
-    private static $formats = array('ipv6');
27
-
28
-    /**
29
-     * Construct and set up the regular expression for this type
30
-     *
31
-     * @param AbstractObject $parent
32
-     * @param string $definition
33
-     */
34
-    public function __construct(AbstractObject $parent, $definition)
35
-    {
36
-        $this->pattern = self::PATTERN;
37
-
38
-        parent::__construct($parent, $definition);
39
-    }
40
-
41
-    /**
42
-     * Parse a type definition string, assuming it belongs to this type
43
-     *
44
-     * @param string $definition
45
-     * @throws Exception
46
-     */
47
-    protected function parseDefinition($definition)
48
-    {
49
-        $definition = self::trim($definition);
50
-
51
-        $match = array();
52
-        if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
-            throw new Exception("Unparseable IPv6 definition: '{$definition}'");
54
-        }
55
-
56
-        if (!in_array(strtolower($match[1]), self::$formats)) {
57
-            throw new Exception("Not an IPv6: '{$definition}'");
58
-        }
59
-
60
-        $this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
-    }
62
-
63
-    /**
64
-     * Check (and optionally reformat) a default value
65
-     *
66
-     * @param string $value
67
-     * @return string
68
-     * @throws Exception
69
-     */
70
-    protected function validateDefault($value)
71
-    {
72
-        if (empty($value)) {
73
-            throw new Exception("Empty IPv6 default");
74
-        }
75
-
76
-        if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
77
-            throw new Exception("Invalid IPv6 default value: '{$value}'");
78
-        }
79
-
80
-        return $value;
81
-    }
82
-
83
-    public static function getFormats()
84
-    {
85
-        return self::$formats;
86
-    }
87
-
88
-    public static function setFormats(array $formats)
89
-    {
90
-        self::$formats = $formats;
91
-    }
20
+	const PATTERN = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))';
21
+
22
+	/**
23
+	 * List of formats recognized by this class
24
+	 * @var string[]
25
+	 */
26
+	private static $formats = array('ipv6');
27
+
28
+	/**
29
+	 * Construct and set up the regular expression for this type
30
+	 *
31
+	 * @param AbstractObject $parent
32
+	 * @param string $definition
33
+	 */
34
+	public function __construct(AbstractObject $parent, $definition)
35
+	{
36
+		$this->pattern = self::PATTERN;
37
+
38
+		parent::__construct($parent, $definition);
39
+	}
40
+
41
+	/**
42
+	 * Parse a type definition string, assuming it belongs to this type
43
+	 *
44
+	 * @param string $definition
45
+	 * @throws Exception
46
+	 */
47
+	protected function parseDefinition($definition)
48
+	{
49
+		$definition = self::trim($definition);
50
+
51
+		$match = array();
52
+		if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT . self::REGEX_END, $definition, $match) !== 1) {
53
+			throw new Exception("Unparseable IPv6 definition: '{$definition}'");
54
+		}
55
+
56
+		if (!in_array(strtolower($match[1]), self::$formats)) {
57
+			throw new Exception("Not an IPv6: '{$definition}'");
58
+		}
59
+
60
+		$this->default = isset($match[2]) && $match[2] !== '' ? $this->validateDefault($match[2]) : null;
61
+	}
62
+
63
+	/**
64
+	 * Check (and optionally reformat) a default value
65
+	 *
66
+	 * @param string $value
67
+	 * @return string
68
+	 * @throws Exception
69
+	 */
70
+	protected function validateDefault($value)
71
+	{
72
+		if (empty($value)) {
73
+			throw new Exception("Empty IPv6 default");
74
+		}
75
+
76
+		if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
77
+			throw new Exception("Invalid IPv6 default value: '{$value}'");
78
+		}
79
+
80
+		return $value;
81
+	}
82
+
83
+	public static function getFormats()
84
+	{
85
+		return self::$formats;
86
+	}
87
+
88
+	public static function setFormats(array $formats)
89
+	{
90
+		self::$formats = $formats;
91
+	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Info.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
             'termsOfService' => $this->termsofservice,
108 108
             'contact' => $this->contact ? $this->contact->toArray() : null,
109 109
             'license' => $this->license ? $this->license->toArray() : null,
110
-            'version' => (string)$this->version,
110
+            'version' => (string) $this->version,
111 111
         ), parent::toArray()));
112 112
     }
113 113
 
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
 class Info extends AbstractObject
15 15
 {
16 16
 
17
-    /**
18
-     * @var string
19
-     */
20
-    private $title = 'undefined';
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private $description;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    private $termsofservice;
31
-
32
-    /**
33
-     * @var Contact
34
-     */
35
-    private $contact;
36
-
37
-    /**
38
-     * @var License
39
-     */
40
-    private $license;
41
-
42
-    /**
43
-     * @var string|integer|float
44
-     */
45
-    private $version = 0;
46
-
47
-    /**
48
-     * @param string $command
49
-     * @param string $data
50
-     * @return AbstractObject|boolean
51
-     */
52
-    public function handleCommand($command, $data = null)
53
-    {
54
-        switch (strtolower($command)) {
55
-            case 'title':
56
-            case 'description':
57
-            case 'termsofservice':
58
-            case 'version':
59
-                $this->$command = $data;
60
-                return $this;
61
-
62
-            case 'terms': // alias
63
-            case 'tos': // alias
64
-                $this->termsofservice = $data;
65
-                return $this;
66
-
67
-            case 'contact':
68
-                $name = array();
69
-                $url = null;
70
-                $email = null;
71
-                foreach (self::wordSplit($data) as $word) {
72
-                    if (filter_var($word, FILTER_VALIDATE_URL)) {
73
-                        $url = $word;
74
-                    } elseif (filter_var($word, FILTER_VALIDATE_EMAIL)) {
75
-                        $email = $word;
76
-                    } else {
77
-                        $name[] = $word;
78
-                    }
79
-                }
80
-                $name = implode(' ', array_filter($name));
81
-                $this->contact = new Contact($this, $name, $url, $email);
82
-                return $this->contact;
83
-
84
-            case 'license':
85
-                $name = array();
86
-                $url = null;
87
-                foreach (self::wordSplit($data) as $word) {
88
-                    if (filter_var($word, FILTER_VALIDATE_URL)) {
89
-                        $url = $word;
90
-                    } else {
91
-                        $name[] = $word;
92
-                    }
93
-                }
94
-                $name = implode(' ', array_filter($name));
95
-                $this->license = new License($this, $name, $url);
96
-                return $this->license;
97
-        }
98
-
99
-        return parent::handleCommand($command, $data);
100
-    }
101
-
102
-    public function toArray(): array
103
-    {
104
-        return self::arrayFilterNull(array_merge(array(
105
-            'title' => $this->title,
106
-            'description' => $this->description,
107
-            'termsOfService' => $this->termsofservice,
108
-            'contact' => $this->contact ? $this->contact->toArray() : null,
109
-            'license' => $this->license ? $this->license->toArray() : null,
110
-            'version' => (string)$this->version,
111
-        ), parent::toArray()));
112
-    }
113
-
114
-    public function __toString()
115
-    {
116
-        return __CLASS__ . ' \'' . $this->title . '\'';
117
-    }
17
+	/**
18
+	 * @var string
19
+	 */
20
+	private $title = 'undefined';
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private $description;
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	private $termsofservice;
31
+
32
+	/**
33
+	 * @var Contact
34
+	 */
35
+	private $contact;
36
+
37
+	/**
38
+	 * @var License
39
+	 */
40
+	private $license;
41
+
42
+	/**
43
+	 * @var string|integer|float
44
+	 */
45
+	private $version = 0;
46
+
47
+	/**
48
+	 * @param string $command
49
+	 * @param string $data
50
+	 * @return AbstractObject|boolean
51
+	 */
52
+	public function handleCommand($command, $data = null)
53
+	{
54
+		switch (strtolower($command)) {
55
+			case 'title':
56
+			case 'description':
57
+			case 'termsofservice':
58
+			case 'version':
59
+				$this->$command = $data;
60
+				return $this;
61
+
62
+			case 'terms': // alias
63
+			case 'tos': // alias
64
+				$this->termsofservice = $data;
65
+				return $this;
66
+
67
+			case 'contact':
68
+				$name = array();
69
+				$url = null;
70
+				$email = null;
71
+				foreach (self::wordSplit($data) as $word) {
72
+					if (filter_var($word, FILTER_VALIDATE_URL)) {
73
+						$url = $word;
74
+					} elseif (filter_var($word, FILTER_VALIDATE_EMAIL)) {
75
+						$email = $word;
76
+					} else {
77
+						$name[] = $word;
78
+					}
79
+				}
80
+				$name = implode(' ', array_filter($name));
81
+				$this->contact = new Contact($this, $name, $url, $email);
82
+				return $this->contact;
83
+
84
+			case 'license':
85
+				$name = array();
86
+				$url = null;
87
+				foreach (self::wordSplit($data) as $word) {
88
+					if (filter_var($word, FILTER_VALIDATE_URL)) {
89
+						$url = $word;
90
+					} else {
91
+						$name[] = $word;
92
+					}
93
+				}
94
+				$name = implode(' ', array_filter($name));
95
+				$this->license = new License($this, $name, $url);
96
+				return $this->license;
97
+		}
98
+
99
+		return parent::handleCommand($command, $data);
100
+	}
101
+
102
+	public function toArray(): array
103
+	{
104
+		return self::arrayFilterNull(array_merge(array(
105
+			'title' => $this->title,
106
+			'description' => $this->description,
107
+			'termsOfService' => $this->termsofservice,
108
+			'contact' => $this->contact ? $this->contact->toArray() : null,
109
+			'license' => $this->license ? $this->license->toArray() : null,
110
+			'version' => (string)$this->version,
111
+		), parent::toArray()));
112
+	}
113
+
114
+	public function __toString()
115
+	{
116
+		return __CLASS__ . ' \'' . $this->title . '\'';
117
+	}
118 118
 
119 119
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/AbstractPreprocessor.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -13,123 +13,123 @@
 block discarded – undo
13 13
 abstract class AbstractPreprocessor
14 14
 {
15 15
 
16
-    private $defines = array();
17
-    private $stack = array();
18
-
19
-    public function __construct()
20
-    {
21
-        $this->resetDefines();
22
-    }
23
-
24
-    public function resetDefines()
25
-    {
26
-        $this->defines = array();
27
-    }
28
-
29
-    public function addDefines(array $defines)
30
-    {
31
-        $this->defines = array_merge($this->defines, $defines);
32
-    }
33
-
34
-    public function define($name, $value = 1)
35
-    {
36
-        $this->defines[$name] = $value;
37
-    }
38
-
39
-    public function undefine($name)
40
-    {
41
-        unset($this->defines[$name]);
42
-    }
43
-
44
-    protected function getState()
45
-    {
46
-        return empty($this->stack) || end($this->stack);
47
-    }
48
-
49
-    /**
50
-     * Get the first word from a string and remove it from the string.
51
-     *
52
-     * @param string $data
53
-     * @return boolean|string
54
-     */
55
-    private static function wordShift(&$data)
56
-    {
57
-        if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
58
-            $data = $matches[2];
59
-            return $matches[1];
60
-        }
61
-        return false;
62
-    }
63
-
64
-    protected function handle($command, $expression)
65
-    {
66
-        switch (strtolower($command)) {
67
-            case 'if':
68
-                $name = self::wordShift($expression);
69
-                $state = $this->getState();
70
-                if (empty($expression)) {
71
-                    $this->stack[] = $state && !empty($this->defines[$name]);
72
-                } else {
73
-                    $this->stack[] = $state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
74
-                }
75
-                break;
76
-
77
-            case 'ifdef':
78
-                $this->stack[] = $this->getState() && isset($this->defines[$expression]);
79
-                break;
80
-
81
-            case 'ifndef':
82
-                $this->stack[] = $this->getState() && !isset($this->defines[$expression]);
83
-                break;
84
-
85
-            case 'else':
86
-                $state = $this->getState();
87
-                array_pop($this->stack);
88
-                $this->stack[] = !$state;
89
-                break;
90
-
91
-            case 'elif':
92
-                $name = self::wordShift($expression);
93
-                $state = $this->getState();
94
-                array_pop($this->stack);
95
-                if (empty($expression)) {
96
-                    $this->stack[] = !$state && !empty($this->defines[$name]);
97
-                } else {
98
-                    $this->stack[] = !$state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
99
-                }
100
-                break;
101
-
102
-            case 'define':
103
-                $name = self::wordShift($expression);
104
-                $this->defines[$name] = $expression;
105
-                break;
106
-
107
-            case 'undef':
108
-                unset($this->defines[$expression]);
109
-                break;
110
-
111
-            case 'endif':
112
-                array_pop($this->stack);
113
-                break;
114
-
115
-            default:
116
-                return false;
117
-        }
118
-
119
-        return true;
120
-    }
121
-
122
-    public function preprocess($content)
123
-    {
124
-        $this->stack = array();
125
-
126
-        return $this->parseContent($content);
127
-    }
128
-
129
-    public function preprocessFile($filename)
130
-    {
131
-        return $this->preprocess(file_get_contents($filename));
132
-    }
133
-
134
-    abstract protected function parseContent($content);
16
+	private $defines = array();
17
+	private $stack = array();
18
+
19
+	public function __construct()
20
+	{
21
+		$this->resetDefines();
22
+	}
23
+
24
+	public function resetDefines()
25
+	{
26
+		$this->defines = array();
27
+	}
28
+
29
+	public function addDefines(array $defines)
30
+	{
31
+		$this->defines = array_merge($this->defines, $defines);
32
+	}
33
+
34
+	public function define($name, $value = 1)
35
+	{
36
+		$this->defines[$name] = $value;
37
+	}
38
+
39
+	public function undefine($name)
40
+	{
41
+		unset($this->defines[$name]);
42
+	}
43
+
44
+	protected function getState()
45
+	{
46
+		return empty($this->stack) || end($this->stack);
47
+	}
48
+
49
+	/**
50
+	 * Get the first word from a string and remove it from the string.
51
+	 *
52
+	 * @param string $data
53
+	 * @return boolean|string
54
+	 */
55
+	private static function wordShift(&$data)
56
+	{
57
+		if (preg_match('~^(\S+)\s*(.*)$~', $data, $matches) === 1) {
58
+			$data = $matches[2];
59
+			return $matches[1];
60
+		}
61
+		return false;
62
+	}
63
+
64
+	protected function handle($command, $expression)
65
+	{
66
+		switch (strtolower($command)) {
67
+			case 'if':
68
+				$name = self::wordShift($expression);
69
+				$state = $this->getState();
70
+				if (empty($expression)) {
71
+					$this->stack[] = $state && !empty($this->defines[$name]);
72
+				} else {
73
+					$this->stack[] = $state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
74
+				}
75
+				break;
76
+
77
+			case 'ifdef':
78
+				$this->stack[] = $this->getState() && isset($this->defines[$expression]);
79
+				break;
80
+
81
+			case 'ifndef':
82
+				$this->stack[] = $this->getState() && !isset($this->defines[$expression]);
83
+				break;
84
+
85
+			case 'else':
86
+				$state = $this->getState();
87
+				array_pop($this->stack);
88
+				$this->stack[] = !$state;
89
+				break;
90
+
91
+			case 'elif':
92
+				$name = self::wordShift($expression);
93
+				$state = $this->getState();
94
+				array_pop($this->stack);
95
+				if (empty($expression)) {
96
+					$this->stack[] = !$state && !empty($this->defines[$name]);
97
+				} else {
98
+					$this->stack[] = !$state && isset($this->defines[$name]) && $this->defines[$name] == $expression;
99
+				}
100
+				break;
101
+
102
+			case 'define':
103
+				$name = self::wordShift($expression);
104
+				$this->defines[$name] = $expression;
105
+				break;
106
+
107
+			case 'undef':
108
+				unset($this->defines[$expression]);
109
+				break;
110
+
111
+			case 'endif':
112
+				array_pop($this->stack);
113
+				break;
114
+
115
+			default:
116
+				return false;
117
+		}
118
+
119
+		return true;
120
+	}
121
+
122
+	public function preprocess($content)
123
+	{
124
+		$this->stack = array();
125
+
126
+		return $this->parseContent($content);
127
+	}
128
+
129
+	public function preprocessFile($filename)
130
+	{
131
+		return $this->preprocess(file_get_contents($filename));
132
+	}
133
+
134
+	abstract protected function parseContent($content);
135 135
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/Php/Entity/ParserClass.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -15,120 +15,120 @@
 block discarded – undo
15 15
 class ParserClass extends AbstractEntity
16 16
 {
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    public $name = null;
22
-
23
-    /**
24
-     * @var ParserFunction[]
25
-     */
26
-    public $Methods = array();
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    public $extends = null;
32
-
33
-    /**
34
-     * @var string[]
35
-     */
36
-    public $implements = array();
37
-    private $lastStatements = null;
38
-
39
-    public function __construct(Parser $Parser, &$tokens, $Statements)
40
-    {
41
-        if ($Statements) {
42
-            $this->Statements = array_merge($this->Statements, $Statements);
43
-        }
44
-
45
-        $depth = 0;
46
-
47
-        $mode = T_CLASS;
48
-
49
-        $token = current($tokens);
50
-        while ($token) {
51
-            switch ($token[0]) {
52
-                case T_STRING:
53
-                    switch ($mode) {
54
-                        case T_CLASS:
55
-                            $this->name = $token[1];
56
-                            $mode = null;
57
-                            break;
58
-
59
-                        case T_EXTENDS:
60
-                            $Parser->queueClass($token[1]);
61
-                            $this->extends = $token[1];
62
-                            $mode = null;
63
-                            break;
64
-
65
-                        case T_IMPLEMENTS:
66
-                            $Parser->queueClass($token[1]);
67
-                            $this->implements[] = $token[1];
68
-                            break;
69
-                    }
70
-                    break;
71
-
72
-                case '{':
73
-                case T_CURLY_OPEN:
74
-                case T_DOLLAR_OPEN_CURLY_BRACES:
75
-                case T_STRING_VARNAME:
76
-                    $mode = null;
77
-                    ++$depth;
78
-                    break;
79
-
80
-                case '}':
81
-                    --$depth;
82
-                    if ($depth == 0) {
83
-                        if ($this->lastStatements) {
84
-                            $this->Statements = array_merge($this->Statements, $this->lastStatements);
85
-                            $this->lastStatements = null;
86
-                        }
87
-                        return;
88
-                    }
89
-                    break;
90
-
91
-                case T_FUNCTION:
92
-                    $Method = new ParserFunction($Parser, $tokens, $this->lastStatements);
93
-                    $this->Methods[strtolower($Method->name)] = $Method;
94
-                    $this->lastStatements = null;
95
-                    break;
96
-
97
-                case T_EXTENDS:
98
-                    $mode = T_EXTENDS;
99
-                    break;
100
-
101
-                case T_IMPLEMENTS:
102
-                    $mode = T_IMPLEMENTS;
103
-                    break;
104
-
105
-                case T_COMMENT:
106
-                    if ($this->lastStatements) {
107
-                        $this->Statements = array_merge($this->Statements, $this->lastStatements);
108
-                        $this->lastStatements = null;
109
-                    }
110
-                    $Statements = $Parser->tokenToStatements($token);
111
-                    $Parser->queueClassesFromComments($Statements);
112
-                    $this->Statements = array_merge($this->Statements, $Statements);
113
-                    break;
114
-
115
-                case T_DOC_COMMENT:
116
-                    if ($this->lastStatements) {
117
-                        $this->Statements = array_merge($this->Statements, $this->lastStatements);
118
-                    }
119
-                    $Statements = $Parser->tokenToStatements($token);
120
-                    $Parser->queueClassesFromComments($Statements);
121
-                    $this->lastStatements = $Statements;
122
-                    break;
123
-            }
124
-
125
-            $token = next($tokens);
126
-        }
127
-
128
-        if ($this->lastStatements) {
129
-            $this->Statements = array_merge($this->Statements, $this->lastStatements);
130
-            $this->lastStatements = null;
131
-        }
132
-    }
18
+	/**
19
+	 * @var string
20
+	 */
21
+	public $name = null;
22
+
23
+	/**
24
+	 * @var ParserFunction[]
25
+	 */
26
+	public $Methods = array();
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	public $extends = null;
32
+
33
+	/**
34
+	 * @var string[]
35
+	 */
36
+	public $implements = array();
37
+	private $lastStatements = null;
38
+
39
+	public function __construct(Parser $Parser, &$tokens, $Statements)
40
+	{
41
+		if ($Statements) {
42
+			$this->Statements = array_merge($this->Statements, $Statements);
43
+		}
44
+
45
+		$depth = 0;
46
+
47
+		$mode = T_CLASS;
48
+
49
+		$token = current($tokens);
50
+		while ($token) {
51
+			switch ($token[0]) {
52
+				case T_STRING:
53
+					switch ($mode) {
54
+						case T_CLASS:
55
+							$this->name = $token[1];
56
+							$mode = null;
57
+							break;
58
+
59
+						case T_EXTENDS:
60
+							$Parser->queueClass($token[1]);
61
+							$this->extends = $token[1];
62
+							$mode = null;
63
+							break;
64
+
65
+						case T_IMPLEMENTS:
66
+							$Parser->queueClass($token[1]);
67
+							$this->implements[] = $token[1];
68
+							break;
69
+					}
70
+					break;
71
+
72
+				case '{':
73
+				case T_CURLY_OPEN:
74
+				case T_DOLLAR_OPEN_CURLY_BRACES:
75
+				case T_STRING_VARNAME:
76
+					$mode = null;
77
+					++$depth;
78
+					break;
79
+
80
+				case '}':
81
+					--$depth;
82
+					if ($depth == 0) {
83
+						if ($this->lastStatements) {
84
+							$this->Statements = array_merge($this->Statements, $this->lastStatements);
85
+							$this->lastStatements = null;
86
+						}
87
+						return;
88
+					}
89
+					break;
90
+
91
+				case T_FUNCTION:
92
+					$Method = new ParserFunction($Parser, $tokens, $this->lastStatements);
93
+					$this->Methods[strtolower($Method->name)] = $Method;
94
+					$this->lastStatements = null;
95
+					break;
96
+
97
+				case T_EXTENDS:
98
+					$mode = T_EXTENDS;
99
+					break;
100
+
101
+				case T_IMPLEMENTS:
102
+					$mode = T_IMPLEMENTS;
103
+					break;
104
+
105
+				case T_COMMENT:
106
+					if ($this->lastStatements) {
107
+						$this->Statements = array_merge($this->Statements, $this->lastStatements);
108
+						$this->lastStatements = null;
109
+					}
110
+					$Statements = $Parser->tokenToStatements($token);
111
+					$Parser->queueClassesFromComments($Statements);
112
+					$this->Statements = array_merge($this->Statements, $Statements);
113
+					break;
114
+
115
+				case T_DOC_COMMENT:
116
+					if ($this->lastStatements) {
117
+						$this->Statements = array_merge($this->Statements, $this->lastStatements);
118
+					}
119
+					$Statements = $Parser->tokenToStatements($token);
120
+					$Parser->queueClassesFromComments($Statements);
121
+					$this->lastStatements = $Statements;
122
+					break;
123
+			}
124
+
125
+			$token = next($tokens);
126
+		}
127
+
128
+		if ($this->lastStatements) {
129
+			$this->Statements = array_merge($this->Statements, $this->lastStatements);
130
+			$this->lastStatements = null;
131
+		}
132
+	}
133 133
 
134 134
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/IParser.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
 interface IParser
14 14
 {
15 15
 
16
-    public function parse($file, array $dirs = array());
16
+	public function parse($file, array $dirs = array());
17 17
 }
Please login to merge, or discard this patch.
SwaggerGen/Parser/Text/Preprocessor.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@
 block discarded – undo
18 18
 class Preprocessor extends AbstractPreprocessor
19 19
 {
20 20
 
21
-    protected function parseContent($content)
22
-    {
23
-        $pattern = '/\\s*([a-z]+)\\s*(.*)\\s*/';
24
-
25
-        $output = '';
26
-
27
-        foreach (preg_split('/(\\R)/m', $content, null, PREG_SPLIT_DELIM_CAPTURE) as $index => $line) {
28
-            if ($index % 2) {
29
-                $output .= $line;
30
-            } else {
31
-                $match = array();
32
-                if (preg_match($pattern, $line, $match) === 1) {
33
-                    if (!$this->handle($match[1], $match[2]) && $this->getState()) {
34
-                        $output .= $line;
35
-                    } else {
36
-                        $output .= '';
37
-                    }
38
-                } else {
39
-                    $output .= $line;
40
-                }
41
-            }
42
-        }
43
-
44
-        return $output;
45
-    }
21
+	protected function parseContent($content)
22
+	{
23
+		$pattern = '/\\s*([a-z]+)\\s*(.*)\\s*/';
24
+
25
+		$output = '';
26
+
27
+		foreach (preg_split('/(\\R)/m', $content, null, PREG_SPLIT_DELIM_CAPTURE) as $index => $line) {
28
+			if ($index % 2) {
29
+				$output .= $line;
30
+			} else {
31
+				$match = array();
32
+				if (preg_match($pattern, $line, $match) === 1) {
33
+					if (!$this->handle($match[1], $match[2]) && $this->getState()) {
34
+						$output .= $line;
35
+					} else {
36
+						$output .= '';
37
+					}
38
+				} else {
39
+					$output .= $line;
40
+				}
41
+			}
42
+		}
43
+
44
+		return $output;
45
+	}
46 46
 
47 47
 }
Please login to merge, or discard this patch.