Completed
Push — master ( 8dd974...c015e5 )
by Ma
14:26 queued 04:31
created

CopyCommandAwareTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A cp() 0 13 1
1
<?php
2
3
/**
4
 * Aist Filesystem Component (http://mateuszsitek.com/projects/filesystem)
5
 *
6
 * @copyright Copyright (c) 2017 DIGITAL WOLVES LTD (http://digitalwolves.ltd) All rights reserved.
7
 * @license   http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
8
 */
9
10
namespace Aist\Filesystem\Console\Command\Traits;
11
12
use Symfony\Component\Console\Input\ArrayInput;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
trait CopyCommandAwareTrait
16
{
17
    /**
18
     * @param OutputInterface $output
19
     * @param $source
20
     * @param $target
21
     *
22
     * @return mixed
23
     */
24
    private function cp(OutputInterface $output, $source, $target)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
25
    {
26
        $command = $this->getApplication()->find('filesystem:copy');
0 ignored issues
show
Bug introduced by
It seems like getApplication() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
27
28
        $input = new ArrayInput([
29
            'command' => $command->getName(),
30
            '--source' => $source,
31
            '--target' => $target,
32
            '-f',
33
        ]);
34
35
        return $command->run($input, $output);
36
    }
37
}
38