Ejemplo n.º 1
0
 /**
  * @return string
  */
 private function readPath()
 {
     $uri = $_SERVER['REQUEST_URI'];
     $uriWithoutScript = $this->stringUtility->substringAfter($uri, '.php');
     $path = $this->stringUtility->substringBefore($uriWithoutScript, '?');
     $decodedPath = urldecode($path);
     return $decodedPath;
 }
 public function parseAuthorizationHeaderString($authorizationHeader)
 {
     if (!$this->stringUtility->startsWith($authorizationHeader, self::BASIC_PREFIX)) {
         throw new InvalidAuthorizationHeaderException('Authorization-Header-Value does not start with \'' . self::BASIC_PREFIX . '\'.');
     }
     $baseEncodedCredentials = $this->stringUtility->substringAfter($authorizationHeader, self::BASIC_PREFIX);
     $decodedCredentials = $this->base64Service->decode($baseEncodedCredentials);
     if ($decodedCredentials === '') {
         list($userIdentifier, $password) = ['', ''];
     } else {
         if (!$this->stringUtility->contains($decodedCredentials, self::CREDENTIALS_DELIMITER)) {
             throw new InvalidAuthorizationHeaderException('Decoded credentials are not delimited by \'' . self::CREDENTIALS_DELIMITER . '\'.');
         } else {
             list($userIdentifier, $password) = $this->stringUtility->split($decodedCredentials, self::CREDENTIALS_DELIMITER);
         }
     }
     return new Credentials($userIdentifier, $password);
 }
 /**
  * @param string $string
  * @param string $needle
  * @param string $wantedResult
  *
  * @dataProvider substringAfterDataProvider
  */
 public function testSubstringAfter($string, $needle, $wantedResult)
 {
     $result = $this->stringUtility->substringAfter($string, $needle);
     $this->assertEquals($wantedResult, $result);
 }