seregazhuk /
php-pinterest-bot
| 1 | <?php |
||
| 2 | |||
| 3 | namespace seregazhuk\PinterestBot\Api\Traits; |
||
| 4 | |||
| 5 | use seregazhuk\PinterestBot\Helpers\UrlBuilder; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Trait UploadsImages |
||
| 9 | */ |
||
| 10 | trait UploadsImages |
||
| 11 | { |
||
| 12 | use HandlesRequest; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param string $image |
||
| 16 | * @return string|null |
||
| 17 | */ |
||
| 18 | public function upload($image) |
||
| 19 | { |
||
| 20 | $result = $this->getRequest()->upload($image, UrlBuilder::IMAGE_UPLOAD); |
||
| 21 | |||
| 22 | $response = $this->getResponse(); |
||
| 23 | $response->fillFromJson($result); |
||
| 24 | |||
| 25 | return $response->hasData('success') ? |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 26 | $response->getData('image_url') : |
||
| 27 | null; |
||
| 28 | } |
||
| 29 | } |
||
| 30 |