CommandImmutableOptionsTrait::copyWithOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Equip\Command;
4
5
/**
6
 * Provides immutable option switching functionality for commands.
7
 */
8
trait CommandImmutableOptionsTrait
9
{
10
    /**
11
     * Copy the current command with new options.
12
     *
13
     * @param OptionsInterface $options
14
     *
15
     * @return static
16
     */
17 1
    private function copyWithOptions(OptionsInterface $options)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
18
    {
19 1
        $copy = clone $this;
20 1
        $copy->options = $options;
0 ignored issues
show
Bug introduced by
The property options 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...
21
22 1
        return $copy;
23
    }
24
}
25