-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathConfigurationLoader.php
More file actions
38 lines (31 loc) · 963 Bytes
/
ConfigurationLoader.php
File metadata and controls
38 lines (31 loc) · 963 Bytes
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
<?php
declare(strict_types=1);
namespace Hypernode\Deploy;
use Deployer\Deployer;
use Deployer\Exception\Exception;
use Deployer\Exception\GracefulShutdownException;
use Hypernode\DeployConfiguration\Configuration;
use Throwable;
class ConfigurationLoader
{
/**
* @throws Exception
* @throws GracefulShutdownException
* @throws Throwable
*/
public function load(string $file): Configuration
{
if (!is_readable($file)) {
throw new \RuntimeException(sprintf('No %s file found in project root %s', $file, getcwd()));
}
$configuration = \call_user_func(function () use ($file) {
return require $file;
});
if (!$configuration instanceof Configuration) {
throw new \RuntimeException(
sprintf('%s/deploy.php did not return object of type %s', getcwd(), Configuration::class)
);
}
return $configuration;
}
}