<?php

namespace CouponsPlus\App\Data;

use CouponsPlus\App\Coupon\Tree\Notifications\Notification;
use CouponsPlus\App\Coupon\Tree\Notifications\Notifications;

class NoticesData
{
    /**
     * Get all notices to display
     *
     * @return array Array of notices
     */
    public static function getNotices() : array
    {
        $notifications = Notifications::getInstance()->get();

        return $notifications->map(function (Notification $notification): array {
            return [
                'id'      => $notification->getId(),
                'message' => $notification->getMessage(),
                'type'    => 'info',
                'button'  => array(
                    'text' => $notification->getButton()->getText(),
                    'url'  => $notification->getButton()->getUrl(),
                ),
            ];
        })->getValues()->asArray();
    }
}
