RequestBuilder::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace IBM\Watson\Common;
6
7
use Http\Message\RequestFactory;
8
use IBM\Watson\Common\Util\DiscoveryTrait;
9
use Psr\Http\Message\RequestInterface;
10
11
/**
12
 * RequestBuilder is a wrapper for a message factory to create PSR-7 requests.
13
 */
14
class RequestBuilder implements RequestBuilderInterface
15
{
16
    use DiscoveryTrait;
17
18
    /**
19
     * @var \Http\Message\RequestFactory
20
     */
21
    private $requestFactory;
22
23
    /**
24
     * @param \Http\Message\RequestFactory $requestFactory Request factory to create requests.
25
     */
26
    public function __construct(RequestFactory $requestFactory = null)
27
    {
28
        $this->requestFactory = $requestFactory ?: $this->discoverMessageFactory();
29
    }
30
31
    /**
32
     * Create a PSR-7 request.
33
     *
34
     * @param string                               $method  HTTP method type.
35
     * @param string|UriInterface                  $uri     Request path.
0 ignored issues
show
Bug introduced by
The type IBM\Watson\Common\UriInterface 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...
36
     * @param array                                $headers Request headers.
37
     * @param resource|string|StreamInterface|null $body    Request body.
0 ignored issues
show
Bug introduced by
The type IBM\Watson\Common\StreamInterface 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...
38
     *
39
     * @return \Psr\Http\Message\RequestInterface
40
     */
41
    public function create(string $method, $uri, array $headers = [], $body = null): RequestInterface
42
    {
43
        return $this->requestFactory->createRequest($method, $uri, $headers, $body);
44
    }
45
}
46