Beispiel #1
0
 public function testToSimpleMapArray()
 {
     $this->assertEquals(['realm' => 'panlatent.com', 'access_token' => ''], Str::convertSimpleMapArray('realm="panlatent.com",access_token=""'));
     $this->assertEquals([], Str::convertSimpleMapArray('realm="panlatent.com"ABC,access_token=""'));
 }
Beispiel #2
0
 /**
  * Returns a array from the authorization header.
  *
  * @return array|bool
  */
 public function getAuthorization()
 {
     $authorization = ['type' => '', 'value' => '', 'parameters' => []];
     if ($content = $this->headers->get('AUTHORIZATION')) {
         $content = explode(' ', trim($content, ' '), 3);
         if (is_array($content) && count($content) > 0) {
             $authorization['type'] = ucfirst(strtolower($content[0]));
             if (isset($content[1]) && Str::isSimpleMapFormat($content[1])) {
                 $authorization['parameters'] = Str::convertSimpleMapArray($content[1]);
             } else {
                 isset($content[1]) and $authorization['value'] = $content[1];
                 isset($content[2]) and $authorization['parameters'] = Str::convertSimpleMapArray($content[2]);
             }
             return $authorization;
         }
     }
     return false;
 }