Page MenuHomeWickedGov Phorge

NotificationsBatch.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

NotificationsBatch.php

<?php
namespace MediaWiki\Notification;
use ArrayIterator;
use Countable;
use IteratorAggregate;
/**
* An object representing notification with list of recipients
* @newable
* @since 1.45
*/
class NotificationsBatch implements Countable, IteratorAggregate {
/** @var NotificationEnvelope[] */
private array $envelopes = [];
public function __construct( NotificationEnvelope ...$envelopes ) {
foreach ( $envelopes as $envelope ) {
$this->add( $envelope );
}
}
public function add( NotificationEnvelope $envelope ): void {
$this->envelopes[ spl_object_id( $envelope ) ] = $envelope;
}
public function remove( NotificationEnvelope $envelope ): void {
unset( $this->envelopes[ spl_object_id( $envelope ) ] );
}
/**
* @param callable(NotificationEnvelope): bool $callback Filter, return true to preserve the $envelope
*/
public function filter( $callback ): void {
$this->envelopes = array_filter( $this->envelopes, $callback );
}
public function count(): int {
return count( $this->envelopes );
}
/**
* @return ArrayIterator<NotificationEnvelope>
*/
public function getIterator(): ArrayIterator {
return new ArrayIterator( array_values( $this->envelopes ) );
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Nov 22, 03:47 (1 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d5/e4/0c40ac93b6fc36cea8af51a95730
Default Alt Text
NotificationsBatch.php (1 KB)

Event Timeline