Skip to content

Instantly share code, notes, and snippets.

@joaorobertopb
Created January 4, 2019 03:10
Show Gist options
  • Save joaorobertopb/7e8825adb882deec22b69aee4eabea99 to your computer and use it in GitHub Desktop.
Save joaorobertopb/7e8825adb882deec22b69aee4eabea99 to your computer and use it in GitHub Desktop.
Exemplo em PHP da utilização do princípio Aberto-Fechado ( Open-Closed ) do SOLID
<?php
interface Remuneravel
{
public function remuneracao();
}
class ContratoClt implements Remuneravel
{
public function remuneracao()
{
//...
}
}
class Estagio implements Remuneravel
{
public function remuneracao()
{
//...
}
}
class FolhaDePagamento
{
protected $saldo;
public function calcular(Remuneravel $funcionario)
{
$this->saldo = $funcionario->remuneracao();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment