Skip to content

Commit 0e5ef84

Browse files
committed
feat: added aliases to the FROM command
1 parent 4521fa0 commit 0e5ef84

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Dockerfile/From.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66

77
final readonly class From implements LayerInterface, \Stringable
88
{
9-
public function __construct(private string $source)
10-
{
9+
public function __construct(
10+
private string $source,
11+
private ?string $alias = null,
12+
) {
1113
}
1214

1315
public function __toString(): string
1416
{
15-
return sprintf('FROM %s', $this->source);
17+
if ($this->alias === null) {
18+
return sprintf('FROM %s', $this->source);
19+
}
20+
21+
return sprintf('FROM %s AS %s', $this->source, $this->alias);
1622
}
1723
}

0 commit comments

Comments
 (0)