Alessandro Feitoza
Evangelist PHP | Community Manager/Founder PHP com Rapadura
Alguem Famoso
debaixo dágua
Termo derivado do grego "Exercicio"
<?php
class Util
{
public function menu ($role)
{
if (isset( $this->options[$role] )) {
foreach ($this->options[$role] as $key => $item {
if ( is_array($item) ) {
foreach ($item as $sub_item) {
...
}
}
}
}
}
}
<?php
class Util
{
public function menu ($role)
{
if (isset( $this->options[$role] )) {
foreach ($this->options[$role] as $key => $item {
if ( is_array($item) ) {
foreach ($item as $sub_item) {
...
}
}
}
}
}
}
0
1
2
3
<?php
class Util
{
public function menu ($role)
{
if ( !isset( $this->options[$role] )) {
return false;
}
foreach ($this->options[$role] as $key => $item {
if ( is_array($item) ) {
foreach ($item as $sub_item) {
...
}
}
}
}
}
0
0
1
2
<?php
class Util
{
public function menu ($role)
{
if ( !isset( $this->options[$role] )) {
return false;
}
foreach ($this->options[$role] as $key => $item {
if ( ! is_array($item) ) {
...
continue;
}
foreach ($item as $sub_item) {
...
}
}
}
}
0
0
1
1
<?php
class Auth
{
public function login ($email, $password)
{
if ($email == '') {
return false;
} else {
if ($password == '') {
return false;
} else {
if ($log = $this->searchUserByEmail($email) {
if ($log->password == $password) {
...
} else {
throw new Exception ('Senha Incorreta');
}
} else {
throw new Exception ('Usuário não encontrado');
}
}
}
}
}
<?php
class Auth
{
public function login ($email, $password)
{
if ($email == '' && $password == '') {
return false;
} else {
if ($log = $this->searchUserByEmail($email) {
if ($log->password == $password) {
...
} else {
throw new Exception ('Senha Incorreta');
}
} else {
throw new Exception ('Usuário não encontrado');
}
}
}
}
<?php
class Auth
{
public function login ($email, $password)
{
if ($email == '' && $password == '') {
return false;
}
if ($log = $this->searchUserByEmail($email) {
if ($log->password == $password) {
...
} else {
throw new Exception ('Senha Incorreta');
}
} else {
throw new Exception ('Usuário não encontrado');
}
}
}
<?php
class Auth
{
public function login ($email, $password)
{
if ($email == '' && $password == '') {
return false;
}
$log = $this->searchUserByEmail($email);
if (! $log ) {
throw new Exception ('Usuário não encontrado');
}
if ($log->password == $password) {
...
} else {
throw new Exception ('Senha Incorreta');
}
}
}
<?php
class Auth
{
public function login ($email, $password)
{
if ($email == '' && $password == '') {
return false;
}
$log = $this->searchUserByEmail($email);
if (! $log ) {
throw new Exception ('Usuário não encontrado');
}
if ($log->password != $password) {
throw new Exception ('Senha Incorreta');
}
...
}
}
<?php
class UserDAO
{
public function searchUserByEmail ($email)
{
$select = new Select('tb_user');
$select->from(['email', 'name', 'password'])->where(['email' => $email])->limit(1);
}
}
<?php
class UserDAO
{
public function searchUserByEmail ($email)
{
$select = new Select('tb_user');
$select
->from(['email', 'name', 'password'])
->where(['email' => $email])
->limit(1);
}
}
<?php
class User
{
public function qtd ()
{
...
}
public function delUs ()
{
...
}
}
<?php
class User
{
public function totalUsers ()
{
...
}
public function deleteUser ()
{
...
}
}
<?php
class User
{
public function createUserAndAddToGroup (User $user)
{
}
}
<?php
class User
{
public function createUser (User $user)
{
...
}
public function addToGroup ($userId)
{
...
}
}
<?php
class UserLogged
{
private $name;
private $email;
private $password;
private $config;
private $permission;
private $menu;
}
<?php
class UserLogged
{
private $name;
private $email;
private $password;
}
<?php
class EmailSended
{
private $numberClicks;
public function setNumberClicks($newClicks)
{
$this->numberClicks = $newClicks;
}
public function getNumberClicks()
{
return $this->numberClicks;
}
}
<?php
class EmailSended
{
private $numberClicks;
public function addClick()
{
$this->numberClicks++;
}
public function getNumberClicks()
{
return $this->numberClicks;
}
}
eu@alessandrofeitoza.eu
slides.com/alessandrofeitoza
www.alessandrofeitoza.eu
phpcomrapadura.org
By Alessandro Feitoza
Evangelist PHP | Community Manager/Founder PHP com Rapadura