/** * Get the first cookie with the matching name. * * @param SafeRequest $request Request object. * @param string $name The name of the cookie to retreive. * * @return string|NULL value of the requested cookie or * NULL if the specified cookie is not present. */ public function getCookie($request, $name) { if ($request instanceof SafeRequest == false) { throw new InvalidArgumentException('getCookie expects an instance of SafeRequest.'); } return $request->getCookie($name); }
/** * Test of SafeRequest::getCookie() with valid input. * * @return bool true True on Pass. */ function testGetCookieInputValid() { $req = new SafeRequest(array('cookies' => array('foo' => 'bar'))); $result = $req->getCookie('foo'); $this->assertInternalType('string', $result); $this->assertEquals('bar', $result); }