Passed
Branch master (267be1)
by Eugene
03:10
created

AddWrongFilesToDiskTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 69
ccs 49
cts 49
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B addWrongFilesToDisk() 0 32 1
B assertWrongFilesIsStillHere() 0 27 1
1
<?php
2
namespace Staticus\Resources\Commands;
3
4
use Staticus\Resources\ResourceDOInterface;
5
6
trait AddWrongFilesToDiskTrait
7
{
8
    /**
9
     * Put bad files to the 'disk'
10
     * @param $resourceDO
11
     * @param $content
12
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
13
     */
14 11
    protected function addWrongFilesToDisk(ResourceDOInterface $resourceDO, $content)
15
    {
16 11
        $resourceDO = clone $resourceDO;
17 11
        $resourceDO->setName('another');
18 11
        $filePath = $resourceDO->getFilePath();
19 11
        $this->filesystem->put($filePath, $content);
0 ignored issues
show
Bug introduced by
The property filesystem does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20 11
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
21
22 11
        $resourceDO = clone $resourceDO;
23 11
        $resourceDO->setNameAlternative('another');
24 11
        $filePath = $resourceDO->getFilePath();
25 11
        $this->filesystem->put($filePath, $content);
26 11
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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 11
        $resourceDO = clone $resourceDO;
29 11
        $resourceDO->setBaseDirectory('another');
30 11
        $filePath = $resourceDO->getFilePath();
31 11
        $this->filesystem->put($filePath, $content);
32 11
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
33
34 11
        $resourceDO = clone $resourceDO;
35 11
        $resourceDO->setNamespace('another');
36 11
        $filePath = $resourceDO->getFilePath();
37 11
        $this->filesystem->put($filePath, $content);
38 11
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
39
40 11
        $resourceDO = clone $resourceDO;
41 11
        $resourceDO->setType('wrong-type');
42 11
        $filePath = $resourceDO->getFilePath();
43 11
        $this->filesystem->put($filePath, $content);
44 11
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
45 11
    }
46
47 4
    protected function assertWrongFilesIsStillHere($resourceDO)
48
    {
49 4
        $resourceDO = clone $resourceDO;
50 4
        $resourceDO->setName('another');
51 4
        $filePath = $resourceDO->getFilePath();
52 4
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
53
54 4
        $resourceDO = clone $resourceDO;
55 4
        $resourceDO->setNameAlternative('another');
56 4
        $filePath = $resourceDO->getFilePath();
57 4
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
58
59 4
        $resourceDO = clone $resourceDO;
60 4
        $resourceDO->setBaseDirectory('another');
61 4
        $filePath = $resourceDO->getFilePath();
62 4
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
63
64 4
        $resourceDO = clone $resourceDO;
65 4
        $resourceDO->setNamespace('another');
66 4
        $filePath = $resourceDO->getFilePath();
67 4
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
68
69 4
        $resourceDO = clone $resourceDO;
70 4
        $resourceDO->setType('wrong-type');
71 4
        $filePath = $resourceDO->getFilePath();
72 4
        $this->assertTrue($this->filesystem->has($filePath));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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...
73
    }
74
}