-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieComposerRequest.php
More file actions
75 lines (65 loc) · 2.27 KB
/
Copy pathPieComposerRequest.php
File metadata and controls
75 lines (65 loc) · 2.27 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
72
73
74
75
<?php
declare(strict_types=1);
namespace Php\Pie\ComposerIntegration;
use Composer\IO\IOInterface;
use Php\Pie\DependencyResolver\RequestedPackageAndVersion;
use Php\Pie\Downloading\DownloadUrlMethod;
use Php\Pie\Platform\TargetPlatform;
use function array_map;
use function in_array;
/**
* @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks
*
* @immutable
*/
final class PieComposerRequest
{
/** @var list<string> */
private readonly array $requestedPackageNames;
/**
* @param list<RequestedPackageAndVersion> $requestedPackages
* @param array<string, list<non-empty-string>> $configureOptions Keyed by package name
* @param list<DownloadUrlMethod> $suppressedDownloadUrlMethods
*/
public function __construct(
public readonly IOInterface $pieOutput,
public readonly TargetPlatform $targetPlatform,
public readonly array $requestedPackages,
public readonly PieOperation $operation,
public readonly array $configureOptions,
public readonly bool $attemptToSetupIniFile,
public readonly bool $installAllPackages = false,
public readonly array $suppressedDownloadUrlMethods = [],
) {
$this->requestedPackageNames = array_map(static fn (RequestedPackageAndVersion $request) => $request->package, $this->requestedPackages);
}
/** @return list<non-empty-string> */
public function configureOptionsFor(string $packageName): array
{
return $this->configureOptions[$packageName] ?? [];
}
/**
* Useful for when we don't want to perform any "write" style operations;
* for example just reading metadata about the installed system.
*/
public static function noOperation(
IOInterface $pieOutput,
TargetPlatform $targetPlatform,
): self {
return new PieComposerRequest(
$pieOutput,
$targetPlatform,
[],
PieOperation::Resolve,
[],
false,
);
}
public function isFor(string $packageName): bool
{
if ($this->installAllPackages) {
return true;
}
return in_array($packageName, $this->requestedPackageNames);
}
}