Passed
Push — master ( d0240a...4d00b1 )
by D
02:09
created

StaticWrapperTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 2
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
trait StaticWrapperTrait
6
{
7
    public static function get(string $url)
8
    {
9
        $request = new self($url);
0 ignored issues
show
Unused Code introduced by Robin
The call to PiedWeb\Curl\StaticWrapperTrait::__construct() has too many arguments starting with $url. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

9
        $request = /** @scrutinizer ignore-call */ new self($url);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
10
        $request
11
            ->setDefaultGetOptions()
0 ignored issues
show
Bug introduced by Robin
It seems like setDefaultGetOptions() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
            ->/** @scrutinizer ignore-call */ 
12
              setDefaultGetOptions()
Loading history...
12
            ->setDefaultSpeedOptions()
13
            ->setNoFollowRedirection()
14
            ->setDesktopUserAgent()
15
        ;
16
17
        $response = $request->exec();
0 ignored issues
show
Bug introduced by Robin
It seems like exec() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        /** @scrutinizer ignore-call */ 
18
        $response = $request->exec();
Loading history...
18
19
        return is_int($response) ? $response : $response->getContent();
20
    }
21
}
22