<?php
class msgContato {
private $nomecompleto;
private $email;
private $telefone;
//...
public function getContato($nome, $sobrenome) {
$this->nomecompleto = new NomeCompleto();
$this->nomecompleto->setNome(''.$nome.'');
$this->nomecompleto->setSobrenome(''.$sobrenome.'');
return $this;
}
}
class NomeCompleto{
private $nome;
private $sobrenome;
public function setNome($nome) {
$this->nome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Nome está vazio.</b>';
$this->nome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Nome tem que ter mais de 3 caracteres.</b>';
$this->nome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Nome no maximo 25 caracteres.</b>';
else :
$this->nome = $nome;
endif;
}
public function setSobrenome($sobrenome) {
$this->sobrenome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Sobrenome está vazio.</b>';
elseif (strlen($sobrenome) < 3) : $this->sobrenome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Sobrenome tem que ter mais de 3 caracteres.</b>';
elseif (strlen($sobrenome) > 25) : $this->sobrenome = '<b class="ico_msg error"><i class="fas fa-engine-warning"></i> Sobrenome no maximo 25 caracteres.</b>';
else :
$this->sobrenome = $sobrenome;
endif;
}
}
$a = new msgContato();
var_dump($a->getContato('aaaaaaaa', 'aaaaaaaaaaaaaa')); ?>
PD9waHAgICAgIAogICAgY2xhc3MgbXNnQ29udGF0byB7CgoJCXByaXZhdGUgJG5vbWVjb21wbGV0bzsgCiAgICAgICAgcHJpdmF0ZSAkZW1haWw7CiAgICAgICAgcHJpdmF0ZSAkdGVsZWZvbmU7CiAgICAgICAgLy8uLi4KICAgICAgICAKCQlwdWJsaWMgZnVuY3Rpb24gZ2V0Q29udGF0bygkbm9tZSwgJHNvYnJlbm9tZSkgewoKCQkJJHRoaXMtPm5vbWVjb21wbGV0byA9IG5ldyBOb21lQ29tcGxldG8oKTsKCgkJCSR0aGlzLT5ub21lY29tcGxldG8tPnNldE5vbWUoJycuJG5vbWUuJycpOwoJCQkkdG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