forked from rialto-php/rialto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AbstractEntryPoint.php
47 lines (39 loc) · 1.25 KB
/
AbstractEntryPoint.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
<?php
namespace Nesk\Rialto;
use Nesk\Rialto\Interfaces\ShouldHandleProcessDelegation;
abstract class AbstractEntryPoint
{
use Traits\CommunicatesWithProcessSupervisor;
/**
* Forbidden options for the user.
*
* @var string[]
*/
protected $forbiddenOptions = ['stop_timeout'];
/**
* Instanciate the entry point of the implementation.
*/
public function __construct(
string $connectionDelegatePath,
?ShouldHandleProcessDelegation $processDelegate = null,
array $implementationOptions = [],
array $userOptions = []
) {
$process = new ProcessSupervisor(
$connectionDelegatePath,
$processDelegate,
$this->consolidateOptions($implementationOptions, $userOptions)
);
$this->setProcessSupervisor($process);
}
/**
* Clean the user options.
*/
protected function consolidateOptions(array $implementationOptions, array $userOptions): array
{
// Filter out the forbidden option
$userOptions = array_diff_key($userOptions, array_flip($this->forbiddenOptions));
// Merge the user options with the implementation ones
return array_merge($implementationOptions, $userOptions);
}
}