Skip to content

Conditions

Romain Monteil edited this page Nov 28, 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->and('TopicA', 'TopicB');

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

Or

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

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

Not

$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