PHP Class LaravelFCM\Message\Topics

Create topic or a topic condition
Show file Open project: brozot/laravel-fcm Class Usage Examples

Public Properties

Property Type Description
$conditions of element in the condition

Public Methods

Method Description
andTopic ( string | Closur\Closure $first ) : Topics Add a and condition to the precedent topic set
build ( ) : array | string Transform to array
hasOnlyOneTopic ( ) : boolean Check if only one topic was set
nest ( Closure $callback, $condition )
orTopic ( string | Closur\Closure $first ) : Topics Add a or condition to the precedent topic set
topic ( string $first ) Add a topic, this method should be called before any conditional topic

Private Methods

Method Description
checkIfOneTopicExist ( )
on ( $first, $condition )
topicsForFcm ( $conditions ) : string

Method Details

andTopic() public method

Parenthesis is a closure Equivalent of this: **'TopicA' in topic' && 'TopicB' in topics** $topic = new Topics(); $topic->topic('TopicA') ->anTopic('TopicB'); Equivalent of this: **'TopicA' in topics || ('TopicB' in topics && 'TopicC' in topics)** $topic = new Topics(); $topic->topic('TopicA') ->orTopic(function($condition) { $condition->topic('TopicB')->AndTopic('TopicC'); }); > Note: Only two operators per expression are supported by fcm
public andTopic ( string | Closur\Closure $first ) : Topics
$first string | Closur\Closure topicName or closure
return Topics

build() public method

Transform to array
public build ( ) : array | string
return array | string

hasOnlyOneTopic() public method

Check if only one topic was set
public hasOnlyOneTopic ( ) : boolean
return boolean

nest() public method

public nest ( Closure $callback, $condition )
$callback Closure
$condition

orTopic() public method

Parenthesis is a closure Equivalent of this: **'TopicA' in topic' || 'TopicB' in topics** $topic = new Topics(); $topic->topic('TopicA') ->orTopic('TopicB'); Equivalent of this: **'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)** $topic = new Topics(); $topic->topic('TopicA') ->andTopic(function($condition) { $condition->topic('TopicB')->orTopic('TopicC'); }); > Note: Only two operators per expression are supported by fcm
public orTopic ( string | Closur\Closure $first ) : Topics
$first string | Closur\Closure topicName or closure
return Topics

topic() public method

Add a topic, this method should be called before any conditional topic
public topic ( string $first )
$first string topicName

Property Details

$conditions public property

of element in the condition
public $conditions