Completed
Push — analysis-D2M1DL ( 825c2b )
by Arnaud
06:16 queued 11s
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().'/'.$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.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

41
        $cacheDirImages = $this->config->getDestinationDir().'/'.$this->config->get('cache.dir').'/'./** @scrutinizer ignore-type */ $this->config->get('cache.images.dir');
Loading history...
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

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