-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsolid_04_isp_original.php
More file actions
51 lines (43 loc) · 969 Bytes
/
solid_04_isp_original.php
File metadata and controls
51 lines (43 loc) · 969 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/*
ISP The Interface Segregation Principle
Make fine grained interfaces that are client specific.
*/
interface Birds
{
public function setLocation($longitude, $latitude);
public function setAltitude($altitude);
public function renderize();
}
class Parrot implements Birds
{
public function setLocation($longitude, $latitude)
{
//Do something
}
public function setAltitude($altitude)
{
//Do something
}
public function renderize()
{
//Do something
}
}
class Penguin implements Birds
{
public function setLocalizacao($longitude, $latitude)
{
//Do something
}
// The Birds Interface is forcing the Penguin Class to implement this method.
// This violates the ISP principle
public function setAltitude($altitude)
{
//Do nothing ... Penguins are birds that don't fly!
}
public function renderize()
{
//Do something
}
}