LaravelFCM\Message\Options::toArray PHP Method

toArray() public method

Transform Option to array
public toArray ( ) : array
return array
    function toArray()
    {
        $contentAvailable = $this->contentAvailable ? true : null;
        $delayWhileIdle = $this->delayWhileIdle ? true : null;
        $dryRun = $this->isDryRun ? true : null;
        $options = ['collapse_key' => $this->collapseKey, 'priority' => $this->priority, 'content_available' => $contentAvailable, 'delay_while_idle' => $delayWhileIdle, 'time_to_live' => $this->timeToLive, 'restricted_package_name' => $this->restrictedPackageName, 'dry_run' => $dryRun];
        return array_filter($options);
    }

Usage Example

Example #1
0
 /**
  * get Options transformed
  *
  * @return array
  */
 protected function getOptions()
 {
     $options = $this->options ? $this->options->toArray() : [];
     if ($this->topic && !$this->topic->hasOnlyOneTopic()) {
         $options = array_merge($options, $this->topic->build());
     }
     return $options;
 }