Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
14.29% covered (danger)
14.29%
2 / 14
Flash
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
20.74
14.29% covered (danger)
14.29%
2 / 14
 display
0.00% covered (danger)
0.00%
0 / 1
20.74
14.29% covered (danger)
14.29%
2 / 14
<?php
declare(strict_types=1);
namespace Eywa\Message\Flash {
    use Eywa\Exception\Kedavra;
    use Eywa\Session\Session;
    class Flash extends Session
    {
        /**
         * @return string
         *
         * @throws Kedavra
         *
         */
        public function display(): string
        {
            if (cli()) {
                return  '';
            }
            $success_class = config('alert', 'success-class');
            $failure_class = config('alert', 'failure-class');
            $result = '';
            foreach ([SUCCESS,FAILURE] as $key) {
                $success = equal($key, SUCCESS);
                $message = $this->get($key);
                $this->destroy([$key]);
                if (def($message)) {
                    return $success
                    ? '<div class="' . $success_class . '" role="alert">' . $message . '</div>'
                    : '<div class="' . $failure_class . '" role="alert">' . $message . '</div>';
                }
            }
            return  $result;
        }
    }
}