Completed
Pull Request — master (#27)
by
unknown
06:13
created

MixedContentLinkedCssExtractor   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A extract() 0 9 1
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use GuzzleHttp\Psr7\Uri;
6
use Psr\Http\Message\UriInterface;
7
8
class MixedContentLinkedCssExtractor
9
{
10
    public static function extract(string $css, UriInterface $cssUri, UriInterface $linkedByUri): array
11
    {
12
        $pattern = '/url\((http:\/\/.*?)\)/m';
13
        $matches = [];
14
        preg_match_all($pattern, $css, $matches);
15
        return collect($matches[1])->map(function ($item, $i) use ($cssUri, $linkedByUri) {
0 ignored issues
show
Unused Code introduced by
The parameter $i is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
            return new MixedContent($cssUri, new Uri($item), $linkedByUri);
17
        })->toArray();
18
    }
19
}
20