예제 #1
0
 protected function morph($content)
 {
     $encoding = mb_detect_encoding($content, array('utf-8', 'iso-8859-1', 'windows-1251'));
     if ($encoding !== 'UTF-8') {
         $content = iconv($encoding, 'UTF-8', $content);
     }
     return Utils::parseJson($content);
 }
예제 #2
0
파일: Base.php 프로젝트: lrusev/bump-common
 protected function parseJSON($content, $detectEncoding = array('utf-8', 'iso-8859-1', 'windows-1251'))
 {
     if (!empty($detectEncoding)) {
         $encoding = mb_detect_encoding($content, $detectEncoding);
         if ($encoding !== 'UTF-8') {
             $content = iconv($encoding, 'UTF-8', $content);
         }
     }
     return Utils::parseJson($content);
 }
예제 #3
0
 public function __toString()
 {
     $contentType = $this->first()->getContentType();
     $data = $this->getData();
     switch ($contentType) {
         case 'application/json':
             $content = json_encode($data);
             break;
         case 'application/xml':
             $content = Utils::convertToXML($this->getData(), 'result', array($this, 'normalizeKey'));
             break;
         default:
             throw new \RuntimeException("Unsupported multi-response content type: {$contentType}");
     }
     return $content;
 }
예제 #4
0
 public function __toString()
 {
     return Utils::convertToXML($this->getData(), 'result', array($this, 'normalizeKey'));
 }