MoveFilesSubject   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A import() 0 14 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Converter\Subjects\MoveFilesSubject
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-converter
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Converter\Subjects;
22
23
/**
24
 * Move files subject implementation.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2016 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/techdivision/import-converter
30
 * @link      http://www.techdivision.com
31
 */
32
class MoveFilesSubject extends \TechDivision\Import\Subjects\MoveFilesSubject
33
{
34
35
    /**
36
     * Imports the content of the file with the passed filename.
37
     *
38
     * @param string $serial   The serial of the actual import
39
     * @param string $filename The filename to process
40
     *
41
     * @return void
42
     * @throws \Exception Is thrown, if the import can't be processed
43
     */
44
    public function import($serial, $filename)
45
    {
46
47
        // initialize the serial/filename
48
        $this->setSerial($serial);
49
        $this->setFilename($filename);
50
51
        // query whether the new source directory has to be created or not
52
        if (!$this->isDir($newSourceDir = $this->getConfiguration()->getTargetDir())) {
53
            $this->mkdir($newSourceDir);
54
        }
55
56
        // move the file to the new source directory
57
        $this->rename($filename, sprintf('%s/%s', $newSourceDir, basename($filename)));
58
    }
59
}
60