Esempio n. 1
0
 /**
  * @param $pathOrString
  *
  * @return Server[]
  * @since 1.0
  */
 public static function fileOrContent($pathOrString)
 {
     $isPath = stristr($pathOrString, DIRECTORY_SEPARATOR) || file_exists($pathOrString);
     if ($isPath) {
         $scope = Scope::fromFile($pathOrString);
     } else {
         $scope = Scope::fromString($pathOrString);
     }
     $results = [];
     foreach ($scope->getDirectives() as $directive) {
         if ($directive->getName() === 'server' && $directive->getChildScope() !== null) {
             $tmp = new static();
             $tmp->iterateDirectives($directive->getChildScope()->getDirectives());
             $results[] = $tmp;
         }
     }
     return $results;
 }
 private static function newDirectiveWithScope($nameString, Text $scopeString)
 {
     $scopeString->inc();
     list($name, $value) = self::processText($nameString);
     $directive = new Directive($name, $value);
     $comment = self::checkRestOfTheLineForComment($scopeString);
     if (false !== $comment) {
         $directive->setComment($comment);
     }
     $childScope = Scope::fromString($scopeString);
     $childScope->setParentDirective($directive);
     $directive->setChildScope($childScope);
     $scopeString->inc();
     $comment = self::checkRestOfTheLineForComment($scopeString);
     if (false !== $comment) {
         $directive->setComment($comment);
     }
     return $directive;
 }
Esempio n. 3
0
 public function testEmptyStringFromString()
 {
     $s = Scope::fromString("");
     $this->assertTrue($s->isEmpty());
 }
Esempio n. 4
0
 public function getState($clientConfigId, $state)
 {
     $collection = $this->mongo->selectCollection($this->db, 'state');
     $result = $collection->findOne(array('client_config_id' => $clientConfigId, 'state' => $state));
     if (null !== $result) {
         $result['scope'] = Scope::fromString($result['scope']);
         return new fkooman\OAuth\Client\State($result);
     }
     return false;
 }