Completed
Push — Assets/Image ( 2bb3c8...b9f49d )
by Arnaud
06:12 queued 14s
created

CacheCopy::init()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 8
rs 10
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 cached files.
15
 */
16
class CacheCopy extends StaticCopy
17
{
18
    protected $count = 0;
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function init($options)
24
    {
25
        $cacheDir = $this->config->getDestinationDir().'/'.$this->config->get('cache.dir');
0 ignored issues
show
Bug introduced by
Are you sure $this->config->get('cache.dir') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        $cacheDir = $this->config->getDestinationDir().'/'./** @scrutinizer ignore-type */ $this->config->get('cache.dir');
Loading history...
26
        if ($this->config->get('cache.external')) {
27
            $cacheDir = $this->config->get('cache.dir');
28
        }
29
        if (Util::getFS()->exists($cacheDir)) {
30
            $this->process = true;
31
        }
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function process()
38
    {
39
        call_user_func_array($this->builder->getMessageCb(), ['COPY', 'Copying cache']);
40
41
        $cacheDirImages = $this->config->getDestinationDir().'/'
42
            .$this->config->get('cache.dir').'/'.$this->config->get('cache.images.dir');
0 ignored issues
show
Bug introduced by
Are you sure $this->config->get('cache.dir') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
            ./** @scrutinizer ignore-type */ $this->config->get('cache.dir').'/'.$this->config->get('cache.images.dir');
Loading history...
Bug introduced by
Are you sure $this->config->get('cache.images.dir') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
            .$this->config->get('cache.dir').'/'./** @scrutinizer ignore-type */ $this->config->get('cache.images.dir');
Loading history...
43
        if ($this->config->get('cache.external')) {
44
            $cacheDirImages = $this->config->get('cache.dir').'/'.$this->config->get('cache.images.dir');
45
        }
46
        if ($this->copy($cacheDirImages, 'images')) {
47
            if ((bool) $this->config->get('cache.enabled') === false) {
48
                Util::getFS()->remove($cacheDirImages);
49
            }
50
        }
51
52
        call_user_func_array($this->builder->getMessageCb(), ['COPY_PROGRESS', 'Start copy', 0, $this->count]);
53
        call_user_func_array($this->builder->getMessageCb(), ['COPY_PROGRESS', 'Copied', $this->count, $this->count]);
54
    }
55
}
56