318 lines
6.6 KiB
PHP
318 lines
6.6 KiB
PHP
<?php
|
|
/**
|
|
* Classe ClientValidate.class.php
|
|
* @filesource
|
|
* @autor Kenio de Souza
|
|
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
|
* @package vendor
|
|
* @subpackage controller/client
|
|
* @version 1.0
|
|
* @date 07/08/2024
|
|
*/
|
|
|
|
|
|
/** Defino o local onde esta a classe */
|
|
namespace vendor\controller\client;
|
|
|
|
/** Importação de classes */
|
|
use vendor\controller\main\Main;
|
|
|
|
class ClientValidate
|
|
{
|
|
/** Declaro as variavéis da classe */
|
|
private $Main = null;
|
|
private $errors = array();
|
|
private $info = null;
|
|
private $clientId = null;
|
|
private $cns = null;
|
|
private $name = null;
|
|
private $dateRegister = null;
|
|
private $state = null;
|
|
private $city = null;
|
|
private $responsible = null;
|
|
private $consultant = null;
|
|
private $typeContract = null;
|
|
|
|
/** Construtor da classe */
|
|
function __construct()
|
|
{
|
|
|
|
/** Instânciamento da classe de validação */
|
|
$this->Main = new Main();
|
|
|
|
}
|
|
|
|
/** Método trata campo client_id */
|
|
public function setClientId(int $clientId) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->clientId = isset($clientId) ? $this->Main->antiInjection($clientId) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->clientId))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo "client_id", deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo cns */
|
|
public function setCns(string $cns) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->cns = isset($cns) ? $this->Main->antiInjection($cns) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->cns))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo CNS deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo name */
|
|
public function setName(string $name) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->name = isset($name) ? $this->Main->antiInjection($name) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->name))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo "name", deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo date_register */
|
|
public function setDateRegister(string $dateRegister) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->dateRegister = isset($dateRegister) ? $this->Main->antiInjection($dateRegister) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->dateRegister))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo "date_register", deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo state */
|
|
public function setState(string $state) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->state = isset($state) ? $this->Main->antiInjection($state) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->state))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo Estado/UF deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo city */
|
|
public function setCity(string $city) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->city = isset($city) ? $this->Main->antiInjection($city) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->city))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo "cidade deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo responsible */
|
|
public function setResponsible(string $responsible) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->responsible = isset($responsible) ? $this->Main->antiInjection($responsible) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->responsible))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo responsável deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo consultant */
|
|
public function setConsultant(string $consultant) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->consultant = isset($consultant) ? $this->Main->antiInjection($consultant) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->consultant))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo consultor deve ser informado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método trata campo type_contract */
|
|
public function setTypeContract(string $typeContract) : void
|
|
{
|
|
|
|
/** Trata a entrada da informação */
|
|
$this->typeContract = isset($typeContract) ? $this->Main->antiInjection($typeContract) : null;
|
|
|
|
/** Verifica se a informação foi informada */
|
|
if(empty($this->typeContract))
|
|
{
|
|
|
|
/** Adição de elemento */
|
|
array_push($this->errors, 'O campo contrato deve ser selecionado');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Método retorna campo client_id */
|
|
public function getClientId() : ? int
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (int)$this->clientId;
|
|
|
|
}
|
|
|
|
/** Método retorna campo cns */
|
|
public function getCns() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->cns;
|
|
|
|
}
|
|
|
|
/** Método retorna campo name */
|
|
public function getName() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->name;
|
|
|
|
}
|
|
|
|
/** Método retorna campo date_register */
|
|
public function getDateRegister() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->dateRegister;
|
|
|
|
}
|
|
|
|
/** Método retorna campo state */
|
|
public function getState() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->state;
|
|
|
|
}
|
|
|
|
/** Método retorna campo city */
|
|
public function getCity() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->city;
|
|
|
|
}
|
|
|
|
/** Método retorna campo responsible */
|
|
public function getResponsible() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->responsible;
|
|
|
|
}
|
|
|
|
/** Método retorna campo consultant */
|
|
public function getConsultant() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->consultant;
|
|
|
|
}
|
|
|
|
/** Método retorna campo type_contract */
|
|
public function getTypeContract() : ? string
|
|
{
|
|
|
|
/** Retorno da informação */
|
|
return (string)$this->typeContract;
|
|
|
|
}
|
|
|
|
public function getErrors(): ? string
|
|
{
|
|
|
|
/** Verifico se deve informar os erros */
|
|
if (count($this->errors)) {
|
|
|
|
/** Verifica a quantidade de erros para informar a legenda */
|
|
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
|
|
|
/** Lista os erros */
|
|
foreach ($this->errors as $keyError => $error) {
|
|
|
|
/** Monto a mensagem de erro */
|
|
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
|
|
|
}
|
|
|
|
/** Retorno os erros encontrados */
|
|
return (string)$this->info;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function __destruct(){}
|
|
|
|
}
|