/** * @covers NginxStatus::setActiveConnections * @covers NginxStatus::setAcceptedRequests * @covers NginxStatus::setHandledRequests * @covers NginxStatus::setStatusReading * @covers NginxStatus::setStatusWriting * @covers NginxStatus::setStatusWaiting * @covers NginxStatus::setRequestsPerConnection */ public function testSetter() { $this->assertTrue(self::$status->setActiveConnections(1) instanceof NginxStatus); self::$status->setAcceptedRequests(2); self::$status->setHandledRequests(3); self::$status->setStatusReading(4); self::$status->setStatusWriting(5); self::$status->setStatusWaiting(6); self::$status->setRequestsPerConnection(7.123); }
/** * @return NginxStatus * @throws NginxStatusException */ public function parse() { $result = new NginxStatus(); if (!count($this->statusPageContent) == 4) { throw new NginxStatusException("Result seems to be invalid!", 2); } $tmpRow = array(); for ($i = 0; $i < count($this->statusPageContent); $i++) { preg_match($this->getRegex()[$i], $this->statusPageContent[$i], $tmpRow[$i]); } $result->setActiveConnections($tmpRow[0][1]); $result->setAcceptedRequests($tmpRow[2][1]); $result->setHandledRequests($tmpRow[2][3]); $result->setRequestsPerConnection($tmpRow[2][1] / $tmpRow[2][3]); $result->setStatusReading($tmpRow[3][1]); $result->setStatusWriting($tmpRow[3][2]); $result->setStatusWaiting($tmpRow[3][3]); return $result; }