code: 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;
      }
docs: Returns the notifications, optionally filtered by type.
  
  @param string $type
  
  @return ArrayCollection|NotificationInterface[]