Passed
Push — fix-assets-images-managment ( a7deda...445b39 )
by Arnaud
06:17 queued 39s
created

AssetsCopy::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 0
loc 13
rs 10
c 1
b 0
f 0
1
<?php
2
/*
3
 * Copyright (c) Arnaud Ligny <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Cecil\Step;
10
11
use Cecil\Util;
12
13
/**
14
 * Copy assets files.
15
 */
16
class AssetsCopy extends StaticCopy
17
{
18
    protected $count = 0;
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function init($options)
24
    {
25
        $this->process = true;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function process()
32
    {
33
        call_user_func_array($this->builder->getMessageCb(), ['COPY', 'Copying assets']);
34
35
        $cacheDirImages = $this->config->getCachePath().'/'.(string) $this->config->get('cache.images.dir');
36
        if ($this->copy($cacheDirImages, 'images')) {
37
            if ((bool) $this->config->get('cache.enabled') === false) {
38
                Util::getFS()->remove($cacheDirImages);
39
            }
40
        }
41
42
        call_user_func_array($this->builder->getMessageCb(), ['COPY_PROGRESS', 'Start copy', 0, $this->count]);
43
        call_user_func_array($this->builder->getMessageCb(), ['COPY_PROGRESS', 'Copied', $this->count, $this->count]);
44
    }
45
}
46