UploadsImages   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 8
c 1
b 1
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A upload() 0 10 2
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