Alguem Famoso
debaixo dágua
Termo derivado do grego "Exercicio"
Jeff Bay - 2004
<?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)
{
$this->database->select('tb_user')->from(['email', 'name', 'password'])->where(['email' => $email])->limit(1);
}
}
<?php
class UserDAO
{
public function searchUserByEmail ($email)
{
$this->database->select('tb_user')
->from(['email', 'name', 'password'])
->where(['email' => $email])
->limit(1);
}
}
<?php
class UserDAO
{
public function searchUserByEmail ($email)
{
$this
->database
->select('tb_user')
->from(['email', 'name', 'password'])
->where(['email' => $email])
->limit(1);
}
}
Exemplo com outra linguagem
document.getElementById('name').style.borderColor = 'red';
document
.getElementById('name')
.style
.borderColor = 'red';
React.useEffect(() => {
fetch('/api/customers').then(res => res.json()).then(json => setCustomers(json));
}, []);
React.useEffect(() => {
fetch('/api/customers')
.then(res => res.json())
.then(json => setCustomers(json));
}, []);
const values = Array.from(document.querySelectorAll('input[type="radio"]')).map(item => item.value.toUpperCase());
const inputs = document.querySelectorAll('input[type="radio"]');
const values = Array.from(inputs).map(item => item.value.toUpperCase());
const inputs = Array.from(
document.querySelectorAll('input[type="radio"]')
);
const values = inputs.map(item => {
return item.value.toUpperCase();
});
<?php
class User
{
public function qtd (): int
{
...
}
public function delUs (): void
{
...
}
}
<?php
class User
{
public function totalUsers (): int
{
...
}
public function deleteUser (): void
{
...
}
}
<?php
class User
{
public function createUserAndAddToGroup (User $user): void
{
}
}
<?php
class User
{
public function createUser (User $user): void
{
...
}
public function addToGroup ($userId): void
{
...
}
}
<?php
class UserLogged
{
private string $name;
private string $email;
private string $password;
private Config $config;
private bool $permission;
private array $menu;
}
<?php
class UserLogged
{
private string $name;
private string $email;
private string $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;
}
}
@alessandro_feitoza
phpcomrapadura.org
alessandrofeitoza.github.io/slides