Skip to content

Conditions

Romain Monteil edited this page Sep 23, 2018 · 6 revisions

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

Usage

use Kerox\Fcm\Model\Message\Condition;

$condition = new Condition();

AND condition

$condition->and('TopicA', 'TopicB');

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

OR condition

$condition->and('TopicA', 'TopicB');

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

NOT condition

$condition->not('TopicA');

Result: !('TopicA' in topics)

Simple subcondition

$condition->and('TopicA', function () {
    return (new Condition)->or('TopicB', 'TopicC');
});

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

Advanced subcondition

$condition = (new Condition)->and('TopicA', function () {
    return (new Condition)->or('TopicB', function () {
        return (new Condition())->and('TopicC', 'TopicD', function () {
           return (new Condition())->not('TopicE');
        });
    });
});

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

Clone this wiki locally