# pushly/2.4.0/src/php/Models/NotificationAudience.php

Pushly, version 2.4.0. 26 lines.

- Page: https://pluginprobe.com/plugins/pushly/2.4.0/code/src/php/Models/NotificationAudience.php
- Raw: https://pluginprobe.com/plugins/pushly/2.4.0/raw/src/php/Models/NotificationAudience.php
- Modified: 2026-09-08T12:20:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/pushly/2.4.0/code/src/php/Models/NotificationAudience.php#L10-L20`.

```php
<?php

namespace Pushly\Models;

class NotificationAudience implements \JsonSerializable {
	public ?bool $all_subscribers = null;
	public ?array $segment_ids = null;
	public ?array $excluded_segment_ids = null;

	#[\ReturnTypeWillChange]
	public function jsonSerialize(): array {
		$audience = $this->all_subscribers
			? [ 'all_subscribers' => $this->all_subscribers ]
			: [ 'segment_ids' => $this->segment_ids ];

		// Exclusions accompany the audience rather than replacing it: the API
		// accepts excluded_segment_ids alongside any audience type, so an empty
		// targeting selection plus exclusions means "all subscribers except these".
		if ( ! empty( $this->excluded_segment_ids ) ) {
			$audience['excluded_segment_ids'] = $this->excluded_segment_ids;
		}

		return $audience;
	}
}

```
