Last active
January 4, 2019 03:05
-
-
Save joaorobertopb/055ece5cbbc7805c3d73b8552e7af8bb to your computer and use it in GitHub Desktop.
Exemplo em PHP da violação do princípio Aberto-Fechado ( Open-Closed ) 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 | |
class ContratoClt | |
{ | |
public function salario() | |
{ | |
//... | |
} | |
} | |
class Estagio | |
{ | |
public function bolsaAuxilio() | |
{ | |
//... | |
} | |
} | |
class FolhaDePagamento | |
{ | |
protected $saldo; | |
public function calcular($funcionario) | |
{ | |
if ( $funcionario instanceof ContratoClt ) { | |
$this->saldo = $funcionario->salario(); | |
} else if ( $funcionario instanceof Estagio) { | |
$this->saldo = $funcionario->bolsaAuxilio(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment