CopyHandler::renderPath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 2
b 0
f 1
nc 2
nop 2
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 6
rs 10
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\handlers;
12
13
use Yii;
14
15
/**
16
 * Handler for copying.
17
 */
18
class CopyHandler extends BaseHandler
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function renderPath($path, $data)
24
    {
25
        try {
26
            copy($data->getCopy(), $path);
27
        } catch (\Exception $e) {
28
            throw new \RuntimeException("Failed to copy file \"{$data->getCopy()}\" to \"$path\": {$e->getMessage()}");
29
        }
30
        Yii::warning('Copied file: ' . $path);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function parsePath($path, $minimal = null)
37
    {
38
        return;
39
    }
40
}
41