Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • bg-php8
  • release_1.2.0
  • 3.1.1
  • 3.1.0
  • 3.0.0
  • 2.0.1
  • 2.0.0
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.0
13 results

ArrayContainer.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ArrayContainer.php 1.01 KiB
    <?php
    
    namespace UnicaenAlerte\Container\Array;
    
    use UnicaenAlerte\Container\ContainerInterface;
    use UnicaenAlerte\Entity\Db\Alerte;
    
    /**
     * Container basique de type tableau permettant d'ajouter manuellement des alertes.
     */
    class ArrayContainer implements ContainerInterface
    {
        /**
         * Alertes à afficher.
         * @var Alerte[]
         */
        protected array $alertes = [];
    
        public function addAlerte(Alerte $alerte): self
        {
            $this->alertes[] = $alerte;
    
            return $this;
        }
    
        public function addAlerteNew(string $text,
                                     string $title,
                                     string $severity = Alerte::SEVERITY_INFO,
                                     int    $duration = 0): self
        {
            $alerte = Alerte::create(uniqid('ALERTE_'), $text, $title, $severity, $duration);
    
            return $this->addAlerte($alerte);
        }
    
        /**
         * @return array|\UnicaenAlerte\Entity\Db\Alerte[]
         */
        public function fetchAlertes(): array
        {
            return $this->alertes;
        }
    }