Last active
March 26, 2017 16:22
-
-
Save em7v/2b31d68c6f3a29d3ad9c04df09371c94 to your computer and use it in GitHub Desktop.
AutoCollection and Auto class,interface,abstract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface AutoInterface | |
{ | |
public function __construct($marka, $type); | |
public function getMarka(); | |
public function getType(); | |
} | |
interface AutoCollectionInterface | |
{ | |
public function add(Auto $auto); | |
public function delete($id); | |
public function findMarka($marka): Auto; | |
public function findType($type): Auto; | |
public function get(): Array; | |
} | |
abstract class AutoCollectionAbstract | |
{ | |
protected $collection = []; | |
} | |
abstract class AutoAbstract | |
{ | |
protected $marka; | |
protected $type; | |
} | |
class Auto extends AutoAbstract implements AutoInterface | |
{ | |
} | |
class AutoCollection extends AutoCollectionAbstract implements AutoCollectionInterface | |
{ | |
} | |
$lada = new Auto('lada', 'coupe'); | |
$collection = new AutoCollection(); | |
$collection->add($lada); | |
$collection->add(new Auto('mazda', 'coupe')); | |
print_r($collection->get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment