forked from HermanPeeren/releasemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteps.php
More file actions
71 lines (60 loc) · 1.71 KB
/
Steps.php
File metadata and controls
71 lines (60 loc) · 1.71 KB
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
<?php
/**
* @package AkeebaReleaseMaker
* @copyright Copyright (c)2012-2021 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\ReleaseMaker\Configuration\Section;
use Akeeba\ReleaseMaker\Configuration\Configuration;
use Akeeba\ReleaseMaker\Contracts\ConfigurationSection;
use Akeeba\ReleaseMaker\Contracts\StepInterface;
use Akeeba\ReleaseMaker\Exception\InvalidStep;
use Akeeba\ReleaseMaker\Mixin\MagicGetterAware;
use Akeeba\ReleaseMaker\Step\Deploy;
use Akeeba\ReleaseMaker\Step\Items;
use Akeeba\ReleaseMaker\Step\Prepare;
use Akeeba\ReleaseMaker\Step\Publish;
use Akeeba\ReleaseMaker\Step\Release as ReleaseStep;
use Akeeba\ReleaseMaker\Step\Updates;
/**
* Steps configuration section.
*
* @property-read string[] $steps Class names of the steps to follow during the release process
*/
final class Steps implements ConfigurationSection
{
use MagicGetterAware;
private array $steps = [];
/** @noinspection PhpUnusedParameterInspection */
public function __construct(array $configuration, Configuration $parent)
{
$this->setSteps($configuration ?? []);
}
private function setSteps(array $steps)
{
if (empty($steps))
{
$this->steps = [
Prepare::class,
Deploy::class,
ReleaseStep::class,
Items::class,
Publish::class,
Updates::class,
];
return;
}
$this->steps = array_map(function (string $step) {
if (class_exists($step))
{
return $step;
}
$className = '\\Akeeba\\ReleaseMaker\\Step\\' . ucfirst($step);
if (!class_exists($className) || !in_array(StepInterface::class, class_implements($className)))
{
throw new InvalidStep($step);
}
return $className;
}, $steps);
}
}