Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class Movie
- {
- }
- class CoolMovie extends Movie implements MovieInterface
- {
- public function getTitle(): string
- {
- return 'Spider man';
- }
- public function getRating(): int
- {
- return 10;
- }
- }
- class MiniMovie extends Movie implements MovieInterface
- {
- public function getTitle(): string
- {
- return 'Super mini movie';
- }
- public function getRating(): int
- {
- return 7;
- }
- }
- class SuperMovie extends Movie implements MovieInterface
- {
- public function getTitle(): string
- {
- return 'Super movie';
- }
- public function getRating(): int
- {
- return 11;
- }
- }
- interface MovieInterface
- {
- public function getTitle(): string;
- public function getRating(): int;
- }
- $coolMovie = new CoolMovie();
- $miniMovie = new MiniMovie();
- $superMovie = new SuperMovie();
- function getMovie(MovieInterface $movie)
- {
- return $movie->getRating();
- }
- echo getMovie($coolMovie) . PHP_EOL;
- echo getMovie($miniMovie) . PHP_EOL;
- echo getMovie($superMovie) . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement