UploadsImages::upload()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
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
The expression return $response->hasDat...ata('image_url') : null also could return the type array|boolean which is incompatible with the documented return type null|string.
Loading history...
26
            $response->getData('image_url') :
27
            null;
28
    }
29
}
30