Completed
Push — master ( 1e6a21...8dd974 )
by Ma
05:29
created

DumpFileCommandAwareTrait::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
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 View Code Duplication
trait DumpFileCommandAwareTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @param OutputInterface $output
19
     * @param $target
20
     * @param $content
21
     *
22
     * @return integer
23
     */
24
    private function write(OutputInterface $output, $target, $content)
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:dump-file');
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
            '--target' => $target,
31
            '--content' => $content,
32
        ]);
33
34
        return $command->run($input, $output);
35
    }
36
}
37