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

assertWrongFilesIsStillHere()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 22
cts 22
cp 1
rs 8.8571
cc 1
eloc 21
nc 1
nop 1
crap 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
}