Code Duplication    Length = 19-19 lines in 2 locations

SwaggerGen/Swagger/Type/IntegerType.php 1 location

@@ 131-149 (lines=19) @@
128
		return __CLASS__;
129
	}
130
131
	private function validateDefault($value)
132
	{
133
		if (preg_match('~^-?\d+$~', $value) !== 1) {
134
			throw new \SwaggerGen\Exception("Invalid integer default: '{$value}'");
135
		}
136
137
		if ($this->maximum) {
138
			if (($value > $this->maximum) || ($this->exclusiveMaximum && $value == $this->maximum)) {
139
				throw new \SwaggerGen\Exception("Default integer beyond maximum: '{$value}'");
140
			}
141
		}
142
		if ($this->minimum) {
143
			if (($value < $this->minimum) || ($this->exclusiveMinimum && $value == $this->minimum)) {
144
				throw new \SwaggerGen\Exception("Default integer beyond minimum: '{$value}'");
145
			}
146
		}
147
148
		return intval($value);
149
	}
150
151
}
152

SwaggerGen/Swagger/Type/NumberType.php 1 location

@@ 125-143 (lines=19) @@
122
		return __CLASS__;
123
	}
124
125
	private function validateDefault($value)
126
	{
127
		if (preg_match('~^-?(?:\\d*\\.?\\d+|\\d+\\.\\d*)$~', $value) !== 1) {
128
			throw new \SwaggerGen\Exception("Invalid number default: '{$value}'");
129
		}
130
131
		if ($this->maximum) {
132
			if (($value > $this->maximum) || ($this->exclusiveMaximum && $value == $this->maximum)) {
133
				throw new \SwaggerGen\Exception("Default number beyond maximum: '{$value}'");
134
			}
135
		}
136
		if ($this->minimum) {
137
			if (($value < $this->minimum) || ($this->exclusiveMinimum && $value == $this->minimum)) {
138
				throw new \SwaggerGen\Exception("Default number beyond minimum: '{$value}'");
139
			}
140
		}
141
142
		return doubleval($value);
143
	}
144
145
}
146