Download tests/PHPUnit/Framework/Constraint/ResponseCode.php from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/tests/PHPUnit/Framework/Constraint/ResponseCode.php
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/tests/PHPUnit/Framework/Constraint/ResponseCode.php
-
curl -L -o ResponseCode.php https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/tests/PHPUnit/Framework/Constraint/ResponseCode.php
1.53 kB
| /** | |
| * Matomo - free/libre analytics platform | |
| * | |
| * @link https://matomo.org | |
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | |
| */ | |
| namespace Piwik\Tests\Framework\Constraint; | |
| /** | |
| * @deprecated | |
| */ | |
| class ResponseCode extends \PHPUnit\Framework\Constraint\Constraint | |
| { | |
| private $actualCode; | |
| private $value; | |
| /** | |
| * @param integer $value Expected response code | |
| */ | |
| public function __construct($value) | |
| { | |
| parent::__construct(); | |
| $this->value = $value; | |
| } | |
| /** | |
| * Evaluates the constraint for parameter $other. Returns TRUE if the | |
| * constraint is met, FALSE otherwise. | |
| * | |
| * @param mixed $other Value or object to evaluate. | |
| */ | |
| public function matches($other): bool | |
| { | |
| $options = array( | |
| CURLOPT_URL => $other, | |
| CURLOPT_HEADER => true, | |
| CURLOPT_TIMEOUT => 1, | |
| CURLOPT_RETURNTRANSFER => true, | |
| ); | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, $options); | |
| @curl_exec($ch); | |
| $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| curl_close($ch); | |
| $this->actualCode = (int) $responseCode; | |
| return $this->value === $this->actualCode; | |
| } | |
| /** | |
| * Returns a string representation of the constraint. | |
| */ | |
| public function toString(): string | |
| { | |
| return 'does not return response code ' . $this->exporter()->export($this->value) . ' it is ' . $this->actualCode; | |
| } | |
| } | |