-
Notifications
You must be signed in to change notification settings - Fork 10
/
PreconditionInterface.php
93 lines (85 loc) · 3.12 KB
/
PreconditionInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php declare(strict_types=1);
namespace PhpTuf\ComposerStager\API\Precondition\Service;
use PhpTuf\ComposerStager\API\Path\Value\PathInterface;
use PhpTuf\ComposerStager\API\Path\Value\PathListInterface;
use PhpTuf\ComposerStager\API\Process\Service\ProcessInterface;
use PhpTuf\ComposerStager\API\Translation\Value\TranslatableInterface;
/**
* Defines a precondition for an API operation and how to verify it.
*
* @package Precondition
*
* @api This interface is subject to our backward compatibility promise and may be safely depended upon.
*/
interface PreconditionInterface
{
/**
* Gets the name.
*
* E.g., "Example dependency".
*/
public function getName(): TranslatableInterface;
/**
* Gets a short description.
*
* This should probably be kept to one or two sentences, e.g., "The example
* dependency is required in order to perform some relevant action."
*/
public function getDescription(): TranslatableInterface;
/**
* Gets a short status message.
*
* This reflects the actual status of the precondition at runtime and may
* include details for resolving an unfulfilled precondition, e.g., "The
* example dependency is ready," or if unfulfilled, "The example dependency
* cannot be found. Make sure it's installed." If the precondition has
* unfulfilled leaves, the status message from the first one will be returned.
*
* @param int $timeout
* An optional process timeout (maximum runtime) in seconds. If set to
* zero (0), no time limit is imposed.
*/
public function getStatusMessage(
PathInterface $activeDir,
PathInterface $stagingDir,
?PathListInterface $exclusions = null,
int $timeout = ProcessInterface::DEFAULT_TIMEOUT,
): TranslatableInterface;
/**
* Determines whether the precondition is fulfilled.
*
* @param int $timeout
* An optional process timeout (maximum runtime) in seconds. If set to
* zero (0), no time limit is imposed.
*/
public function isFulfilled(
PathInterface $activeDir,
PathInterface $stagingDir,
?PathListInterface $exclusions = null,
int $timeout = ProcessInterface::DEFAULT_TIMEOUT,
): bool;
/**
* Asserts that the precondition is fulfilled.
*
* @param int $timeout
* An optional process timeout (maximum runtime) in seconds. If set to
* zero (0), no time limit is imposed.
*
* @throws \PhpTuf\ComposerStager\API\Exception\PreconditionException
* If the precondition is unfulfilled.
*/
public function assertIsFulfilled(
PathInterface $activeDir,
PathInterface $stagingDir,
?PathListInterface $exclusions = null,
int $timeout = ProcessInterface::DEFAULT_TIMEOUT,
): void;
/**
* Returns a flat array of all concrete preconditions in the contained tree.
*
* This may be valuable for a creating a status report, for example.
*
* @return array<\PhpTuf\ComposerStager\API\Precondition\Service\PreconditionInterface>
*/
public function getLeaves(): array;
}