ContentDisposition::getAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Fracture\Http\Headers;
4
5
class ContentDisposition extends Common
6
{
7
8
    protected $headerName = 'Content-Disposition';
9
10
11 2
    protected function extractData($header)
12
    {
13 2
        $matches = null;
14 2
        preg_match('/^(.+); *name="(?P<name>[^"]+)"(; *filename="(?P<filename>[^"]+)")?/', $header, $matches);
15 2
        return $matches + ['name' => null, 'filename' => null];
16
    }
17
18
19 2
    public function getAttribute($name)
20
    {
21 2
        if (array_key_exists($name, $this->data)) {
22 2
            return $this->data[$name];
23
        }
24 1
        return null;
25
    }
26
}
27