MimeTypeFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A match() 0 4 1
1
<?php
2
namespace VDB\Spider\Filter\Postfetch;
3
4
use VDB\Spider\Filter\PostFetchFilterInterface;
5
use VDB\Spider\Resource;
6
7
/**
8
 * @author matthijs
9
 */
10
class MimeTypeFilter implements PostFetchFilterInterface
11
{
12
    protected $allowedMimeType = '';
13
14
    public function __construct($allowedMimeType)
15
    {
16
        $this->allowedMimeType = $allowedMimeType;
17
    }
18
19
    public function match(Resource $resource)
20
    {
21
        $contentType = $resource->getResponse()->getHeaderLine('Content-Type');
22
        return $contentType !== $this->allowedMimeType;
23
    }
24
}
25