CUrlValidator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 10 1
1
<?php
2
3
namespace Jackal\Downloader\Ext\Youtube\Validator;
4
5
class CUrlValidator implements ValidatorInterface
6
{
7
    public function isValid($url): bool
8
    {
9
        $handle = curl_init($url);
10
        curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'HEAD');
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $ch of curl_setopt() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

10
        curl_setopt(/** @scrutinizer ignore-type */ $handle, CURLOPT_CUSTOMREQUEST, 'HEAD');
Loading history...
11
        curl_setopt($handle, CURLOPT_TIMEOUT, 5);
12
        curl_exec($handle);
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $ch of curl_exec() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

12
        curl_exec(/** @scrutinizer ignore-type */ $handle);
Loading history...
13
        $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $ch of curl_getinfo() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

13
        $httpCode = curl_getinfo(/** @scrutinizer ignore-type */ $handle, CURLINFO_HTTP_CODE);
Loading history...
14
        curl_close($handle);
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $ch of curl_close() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

14
        curl_close(/** @scrutinizer ignore-type */ $handle);
Loading history...
15
16
        return $httpCode < 400;
17
    }
18
}
19