original_string: public function getCookie($key, $domain = '-')
      {
          $domain = strtolower($domain);
          if ($key === null) {
              $cookies = [];
          }
          while (true) {
              if (isset($this->_cookies[$domain])) {
                  foreach ($this->_cookies[$domain] as $path => $list) {
                      if ($key === null) {
                          $cookies = array_merge($list, $cookies);
                      } else {
                          if (isset($list[$key])) {
                              return rawurldecode($list[$key]['value']);
                          }
                      }
                  }
              }
              if (($pos = strpos($domain, '.', 1)) === false) {
                  break;
              }
              $domain = substr($domain, $pos);
          }
          return $key === null ? $cookies : null;
      }
code: public function getCookie($key, $domain = '-')
      {
          $domain = strtolower($domain);
          if ($key === null) {
              $cookies = [];
          }
          while (true) {
              if (isset($this->_cookies[$domain])) {
                  foreach ($this->_cookies[$domain] as $path => $list) {
                      if ($key === null) {
                          $cookies = array_merge($list, $cookies);
                      } else {
                          if (isset($list[$key])) {
                              return rawurldecode($list[$key]['value']);
                          }
                      }
                  }
              }
              if (($pos = strpos($domain, '.', 1)) === false) {
                  break;
              }
              $domain = substr($domain, $pos);
          }
          return $key === null ? $cookies : null;
      }
code_tokens: public function getCookie ( $ key , $ domain = '-' ) { $ domain = strtolower ( $ domain ) ; if ( $ key === null ) { $ cookies = [ ] ; } while ( true ) { if ( isset ( $ this -> _cookies [ $ domain ] ) ) { foreach ( $ this -> _cookies [ $ domain ] as $ path => $ list ) { if ( $ key === null ) { $ cookies = array_merge ( $ list , $ cookies ) ; } else { if ( isset ( $ list [ $ key ] ) ) { return rawurldecode ( $ list [ $ key ] [ 'value' ] ) ; } } } } if ( ( $ pos = strpos ( $ domain , '.' , 1 ) ) === false ) { break ; } $ domain = substr ( $ domain , $ pos ) ; } return $ key === null ? $ cookies : null ; }
docstring: Get cookie value
  @param string $key passing null to get all cookies
  @param string $domain passing '-' to fetch from current session,
  @return array|null|string
docstring_tokens: Get cookie value