alex-kalanis /
remote-request
| 1 | <?php |
||
| 2 | |||
| 3 | namespace kalanis\RemoteRequest\Protocols\Restful; |
||
| 4 | |||
| 5 | |||
| 6 | use kalanis\RemoteRequest\Protocols; |
||
| 7 | |||
| 8 | |||
| 9 | /** |
||
| 10 | * Class Query |
||
| 11 | * @package kalanis\RemoteRequest\Protocols\Restful |
||
| 12 | * Simple RESTful query to remote source |
||
| 13 | */ |
||
| 14 | class Query extends Protocols\Http\Query |
||
| 15 | { |
||
| 16 | 2 | public function isInline(): bool |
|
| 17 | { |
||
| 18 | 2 | return false; |
|
| 19 | } |
||
| 20 | |||
| 21 | 2 | protected function prepareQuery(): parent |
|
| 22 | { |
||
| 23 | 2 | $content = []; |
|
| 24 | 2 | foreach ($this->content as $key => $item) { |
|
| 25 | 2 | if ($item instanceof Protocols\Http\Query\File) { |
|
| 26 | 1 | $content[$key] = [ |
|
| 27 | 1 | 'type' => 'file', |
|
| 28 | 1 | 'filename' => $item->getFilename(), |
|
| 29 | 1 | 'mimetype' => $item->getMimeType(), |
|
| 30 | 1 | 'content64' => base64_encode($item->getContent()), |
|
| 31 | 1 | ]; |
|
| 32 | } else { |
||
| 33 | 2 | $content[$key] = $item->getContent(); |
|
| 34 | } |
||
| 35 | } |
||
| 36 | 2 | $this->contentLength += intval(fwrite($this->contentStream, strval(json_encode($content)))); |
|
| 37 | 2 | return $this; |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 38 | } |
||
| 39 | } |
||
| 40 |