Completed
Pull Request — master (#190)
by
unknown
02:30
created

Downloadable::download()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php namespace Picqer\Financials\Exact\Persistance;
2
3
use \GuzzleHttp\Client;
4
use Picqer\Financials\Exact\Connection;
5
6
trait Downloadable
7
{
8
    /**
9
     * @return Connection
10
     */
11
    abstract function connection();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
12
13
    /**
14
     * @return Binary representation of file
0 ignored issues
show
Bug introduced by
The type Picqer\Financials\Exact\Persistance\Binary was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
     */
16
    public function download()
17
    {
18
        $client = new Client();
19
20
        $uri = $this->Url . '&Download=1';
0 ignored issues
show
Bug Best Practice introduced by
The property Url does not exist on Picqer\Financials\Exact\Persistance\Downloadable. Did you maybe forget to declare it?
Loading history...
21
22
        $headers = [
23
            'Accept' => 'application/json',
24
            'Content-Type' => 'application/json',
25
            'Prefer' => 'return=representation',
26
            'Authorization' => 'Bearer ' . $this->connection->getAccessToken(),
0 ignored issues
show
Bug Best Practice introduced by
The property connection does not exist on Picqer\Financials\Exact\Persistance\Downloadable. Did you maybe forget to declare it?
Loading history...
27
        ];
28
29
        $res = $client->get($uri, [
30
          'headers' => $headers
31
        ]);
32
33
        return $res->getBody();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $res->getBody() returns the type Psr\Http\Message\StreamInterface which is incompatible with the documented return type Picqer\Financials\Exact\Persistance\Binary.
Loading history...
34
    }
35
}
36