vendor/novosga/core/Entity/Senha.php line 102

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Novo SGA project.
  4.  *
  5.  * (c) Rogerio Lino <rogeriolino@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Novosga\Entity;
  11. /**
  12.  * Classe Senha
  13.  * Responsavel pelas informacoes do Senha.
  14.  *
  15.  * @author RogĂ©rio Lino <rogeriolino@gmail.com>
  16.  */
  17. class Senha implements \JsonSerializable
  18. {
  19.     const LENGTH 3;
  20.     /**
  21.      * @var string
  22.      */
  23.     private $sigla;
  24.     /**
  25.      * @var int
  26.      */
  27.     private $numero;
  28.     public function __construct()
  29.     {
  30.     }
  31.     /**
  32.      * Define a sigla da senha.
  33.      *
  34.      * @param char $sigla
  35.      */
  36.     public function setSigla($sigla): self
  37.     {
  38.         $this->sigla $sigla;
  39.         return $this;
  40.     }
  41.     /**
  42.      * Retorna a sigla da senha.
  43.      *
  44.      * @return char $sigla
  45.      */
  46.     public function getSigla()
  47.     {
  48.         return $this->sigla;
  49.     }
  50.     /**
  51.      * Define o numero da senha.
  52.      *
  53.      * @param int $numero
  54.      */
  55.     public function setNumero($numero): self
  56.     {
  57.         $this->numero $numero;
  58.         return $this;
  59.     }
  60.     /**
  61.      * Retorna o numero da senha.
  62.      *
  63.      * @return int $numero
  64.      */
  65.     public function getNumero()
  66.     {
  67.         return $this->numero;
  68.     }
  69.     /**
  70.      * Retorna o numero da senha preenchendo com zero (esquerda).
  71.      *
  72.      * @return string
  73.      */
  74.     public function getNumeroZeros()
  75.     {
  76.         return str_pad($this->getNumero(), self::LENGTH'0'STR_PAD_LEFT);
  77.     }
  78.     /**
  79.      * Retorna a senha formatada para exibicao.
  80.      *
  81.      * @return string
  82.      */
  83.     public function __toString()
  84.     {
  85.         return $this->getSigla() . $this->getNumeroZeros();
  86.     }
  87.     
  88.     public function jsonSerialize()
  89.     {
  90.         return [
  91.             'sigla'  => $this->getSigla(),
  92.             'numero' => $this->getNumero(),
  93.             'format' => $this->__toString(),
  94.         ];
  95.     }
  96. }