Skip to content

Conditions

Romain Monteil edited this page May 20, 2023 · 6 revisions

You can build condition by using the \Kerox\Fcm\Model\Target\Condition class.

Usage

And

use Kerox\Fcm\Model\Target\Condition;

$condition = Condition::and('TopicA', 'TopicB');

Result: 'TopicA' in topics && 'TopicB' in topics

Or

use Kerox\Fcm\Model\Target\Condition;

$condition = Condition::or('TopicA', 'TopicB');

Result: 'TopicA' in topics || 'TopicB' in topics

Not

use Kerox\Fcm\Model\Target\Condition;

$condition = Condition::not('TopicA', 'TopicB');

Result: !('TopicA' in topics)

Simple subcondition

use Kerox\Fcm\Model\Target\Condition;

$condition = Condition::and('TopicA', fn () => Condition::or('TopicB', 'TopicC'));

Result: 'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)

Advanced subcondition

$condition = Condition::and('TopicA', fn () => Condition::or('TopicB', fn () => Condition::and('TopicC', 'TopicD', fn () => Condition::not('TopicE'))));

Result: 'TopicA' in topics && ('TopicB' in topics || ('TopicC' in topics && 'TopicD' in topics && (!('TopicE' in topics))))

Clone this wiki locally