Completed
Push — master ( 90448b...2ebf44 )
by Vladimir
05:45 queued 30s
created

Check::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 8
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Check\http\GuzzleHttpService;
13
14
use JMS\Serializer\Annotation as JMS;
15
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
16
use GuzzleHttp\Message\RequestInterface as GuzzleRequestInterface;
0 ignored issues
show
Bug introduced by
The type GuzzleHttp\Message\RequestInterface 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...
17
use InvalidArgumentException;
18
use Psr\Http\Message\RequestInterface as PsrRequestInterface;
19
use ZendDiagnostics\Check\GuzzleHttpService;
20
use Tvi\MonitorBundle\Check\CheckAbstract;
21
22
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
23
 * @JMS\ExclusionPolicy("all")
24
 *
25
 * @author Vladimir Turnaev <[email protected]>
26
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
27
class Check extends CheckAbstract
28
{
29
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
30
     * @var GuzzleHttpService
31
     */
32
    private $checker;
0 ignored issues
show
Coding Style introduced by
Private member variable "checker" must be prefixed with an underscore
Loading history...
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
35
     * @param string|PsrRequestInterface|GuzzleRequestInterface $requestOrUrl
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     *                                                                        The absolute url to check, or a
37
     *                                                                        fully-formed request instance
38
     * @param array                                             $headers      An array of headers used to create the
39
     *                                                                        request
40
     * @param array                                             $options      An array of guzzle options to use when
41
     *                                                                        sending the request
42
     * @param int                                               $statusCode   The response status code to check
43
     * @param null                                              $content      The response content to check
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $content is correct as it would always require null to be passed?
Loading history...
44
     * @param null|GuzzleClientInterface                        $guzzle       Instance of guzzle to use
45
     * @param string                                            $method       The method of the request
46
     * @param mixed                                             $body         The body of the request (used for POST, PUT
47
     *                                                                        and DELETE requests)
48
     *
49
     * @throws InvalidArgumentException
50
     */
51 2
    public function __construct($requestOrUrl, array $headers = [], array $options = [], $statusCode = 200, $content = null, $guzzle = null, $method = 'GET', $body = null)
52
    {
53 2
        $this->checker = new GuzzleHttpService($requestOrUrl, $headers, $options, $statusCode, $content, $guzzle, $method, $body);
54 2
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
59 2
    public function check()
60
    {
61 2
        return $this->checker->check();
62
    }
63
}
64