Skip to content

Commit 9786c52

Browse files
committed
Add methods to activate/deactivate the command
1 parent fbb0816 commit 9786c52

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Command.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,26 @@ public function isActive() : bool
180180
{
181181
return $this->active;
182182
}
183+
184+
/**
185+
* Activate the command.
186+
*
187+
* @return static
188+
*/
189+
public function activate() : static
190+
{
191+
$this->active = true;
192+
return $this;
193+
}
194+
195+
/**
196+
* Deactivate the command.
197+
*
198+
* @return static
199+
*/
200+
public function deactivate() : static
201+
{
202+
$this->active = false;
203+
return $this;
204+
}
183205
}

tests/CommandTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,13 @@ public function testOptions() : void
4848
$this->command->setOptions(['-a' => 'baz']);
4949
self::assertSame(['-a' => 'baz'], $this->command->getOptions());
5050
}
51+
52+
public function testActive() : void
53+
{
54+
self::assertTrue($this->command->isActive());
55+
$this->command->deactivate();
56+
self::assertFalse($this->command->isActive());
57+
$this->command->activate();
58+
self::assertTrue($this->command->isActive());
59+
}
5160
}

0 commit comments

Comments
 (0)