| 1 | <?php |
||
| 7 | abstract class StandardRule implements Rule |
||
| 8 | { |
||
| 9 | protected $contentTypes = array(); |
||
| 10 | |||
| 11 | public function validate(Response $response) |
||
| 12 | { |
||
| 13 | if (count($this->contentTypes) > 0) { |
||
| 14 | $valid = false; |
||
| 15 | foreach ($this->contentTypes as $validContentType) { |
||
| 16 | if (strpos($response->getContentType(), $validContentType) !== false) { |
||
| 17 | $valid = true; |
||
| 18 | break; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | if (!$valid) { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | } |
||
| 25 | $this->doValidation($response); |
||
| 26 | } |
||
| 27 | |||
| 28 | abstract protected function doValidation(Response $response); |
||
| 29 | |||
| 30 | protected function assert($valueToBeTrue, $errorMessage) |
||
| 36 | } |
||
| 37 |