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