Skip to content

Commit 55d4d8f

Browse files
author
Bastian Schwarz
committed
Added NoOp implementation. Needs logging functions first
1 parent b7433ab commit 55d4d8f

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/task/NoOp.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2023 Bastian Schwarz <bastian@codename-php.de>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\base\task;
19+
20+
use Closure;
21+
22+
/**
23+
* This task does nothing. It is used to create a task that does nothing but is not null.
24+
*/
25+
final class NoOp implements iTaskWithName, iTaskWithDescription {
26+
27+
public Closure $getMessage;
28+
29+
public function __construct(public readonly string $name, public readonly bool $printMessage = false) {
30+
$this->getMessage = static fn(string $name) : string => "No operation task '{$name}' was executed";
31+
}
32+
33+
public function __invoke() : void {
34+
!$this->printMessage ?: '';
35+
}
36+
37+
public function getDescription() : string {
38+
return 'A task that does nothing. Use to disable a task.';
39+
}
40+
41+
public function getName() : string {
42+
return $this->name;
43+
}
44+
}

0 commit comments

Comments
 (0)