-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMovie.php
More file actions
37 lines (29 loc) · 870 Bytes
/
Copy pathMovie.php
File metadata and controls
37 lines (29 loc) · 870 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
<?php
declare(strict_types=1);
namespace App\Behavioral\TemplateMethod;
abstract class Movie
{
protected string $name;
protected int $budget;
protected array $cast = [];
protected string $director;
public function __construct(string $name)
{
$this->name = $name;
}
final public function publish(): void
{
$this->raiseMoney();
$this->castActors();
$this->castDirector();
$this->promote();
}
abstract protected function raiseMoney(): void;
abstract protected function castActors(): void;
abstract protected function castDirector(): void;
protected function promote(): void
{
$actors = implode(", ", $this->cast);
echo "New movie '{$this->name}' directed by {$this->director}. Starring {$actors} and budget of \${$this->budget}!" . PHP_EOL;
}
}