File   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 26
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPhpFileArray() 0 23 2
1
<?php
2
3
namespace SP\Crawler\Element;
4
5
use Guzzlehttp\Psr7;
6
7
/**
8
 * @author    Ivan Kerin <[email protected]>
9
 * @copyright 2015, Clippings Ltd.
10
 * @license   http://spdx.org/licenses/BSD-3-Clause
11
 */
12
class File extends Input
13
{
14 2
    public function getPhpFileArray()
15
    {
16 2
        if ($this->getValue()) {
17 1
            $tmpFile = tempnam(sys_get_temp_dir(), 'crawler-uploaded-file');
18 1
            copy($this->getValue(), $tmpFile);
19
20
            return [
21 1
                'tmp_name' => $tmpFile,
22 1
                'size' => filesize($this->getValue()),
23 1
                'error' => UPLOAD_ERR_OK,
24 1
                'name' => $this->getValue(),
25 1
                'type' => Psr7\mimetype_from_filename($this->getValue())
26 1
            ];
27
        } else {
28
            return [
29 1
                'tmp_name' => '',
30 1
                'size' => '0',
31 1
                'error' => UPLOAD_ERR_NO_FILE,
32 1
                'name' => '',
33
                'type' => ''
34 1
            ];
35
        }
36
    }
37
}
38