Last active
January 5, 2019 03:20
-
-
Save joaorobertopb/3ce7d383954c6a1f32af1de5d5afe126 to your computer and use it in GitHub Desktop.
Exemplo de código PHP que viola o princípio de segregação das interfaces do SOLID.
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 Aves | |
{ | |
public function setLocalizacao($longitude, $latitude); | |
public function setAltitude($altitude); | |
public function renderizar(); | |
} | |
class Papagaio implements Aves | |
{ | |
public function setLocalizacao($longitude, $latitude) | |
{ | |
//Faz alguma coisa | |
} | |
public function setAltitude($altitude) | |
{ | |
//Faz alguma coisa | |
} | |
public function renderizar() | |
{ | |
//Faz alguma coisa | |
} | |
} | |
class Pinguim implements Aves | |
{ | |
public function setLocalizacao($longitude, $latitude) | |
{ | |
//Faz alguma coisa | |
} | |
// A Interface Aves está forçando a Classe Pinguim a implementar esse método. | |
// Isso viola o príncipio ISP | |
public function setAltitude($altitude) | |
{ | |
//Não faz nada... Pinguins são aves que não voam! | |
} | |
public function renderizar() | |
{ | |
//Faz alguma coisa | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment