Skip to content

Instantly share code, notes, and snippets.

@alanwillms
Created October 2, 2015 19:03
Show Gist options
  • Select an option

  • Save alanwillms/9481921000e97ac8c865 to your computer and use it in GitHub Desktop.

Select an option

Save alanwillms/9481921000e97ac8c865 to your computer and use it in GitHub Desktop.
User class after null object (based on an Upcase example)
<?php
class Usuario
{
public function cobrar()
{
$this->assinatura->cobrar($this->getCartaoCredito()); // sem testar por null!
}
public function isPremium()
{
$this->assinatura->isPremium(); // sem testar por null!
}
public function getValorCobrado()
{
return $this->assinatura->getValor(); // sem testar por null!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment