public function getNotifications($type = null)
    {
        if (null !== $type) {
            NotificationTypes::isValidType($type);

            return $this
                ->notifications
                ->filter(function (NotificationInterface $n) use ($type) {
                    return $n->getType() === $type;
                });
        }

        return $this->notifications;
    }