src/Pushman.php
private function validateChannel($channels = [], $returnAsArray = true)
    {
        if ($returnAsArray) {
            if (is_string($channels)) {
                $channels = [$channels];
            }
            if (empty($channels)) {
                return ['public'];
            }
            foreach ($channels as $channel) {
                if (strpos($channel, ' ') !== false) {
                    throw new InvalidChannelException('No spaces are allowed in channel names.');
                }
            }

            return json_encode($channels);
        } else {
            if (empty($channels)) {
                return 'public';
            }
            if (strpos($channels, ' ') !== false) {
                throw new InvalidChannelException('No spaces are allowed in channel names.');
            }

            return $channels;
        }
    }
private function validateChannel($channels = [], $returnAsArray = true)
    {
        if ($returnAsArray) {
            if (is_string($channels)) {
                $channels = [$channels];
            }
            if (empty($channels)) {
                return ['public'];
            }
            foreach ($channels as $channel) {
                if (strpos($channel, ' ') !== false) {
                    throw new InvalidChannelException('No spaces are allowed in channel names.');
                }
            }

            return json_encode($channels);
        } else {
            if (empty($channels)) {
                return 'public';
            }
            if (strpos($channels, ' ') !== false) {
                throw new InvalidChannelException('No spaces are allowed in channel names.');
            }

            return $channels;
        }
    }
private function validateChannel ( $ channels = [ ] , $ returnAsArray = true ) { if ( $ returnAsArray ) { if ( is_string ( $ channels ) ) { $ channels = [ $ channels ] ; } if ( empty ( $ channels ) ) { return [ 'public' ] ; } foreach ( $ channels as $ channel ) { if ( strpos ( $ channel , ' ' ) !== false ) { throw new InvalidChannelException ( 'No spaces are allowed in channel names.' ) ; } } return json_encode ( $ channels ) ; } else { if ( empty ( $ channels ) ) { return 'public' ; } if ( strpos ( $ channels , ' ' ) !== false ) { throw new InvalidChannelException ( 'No spaces are allowed in channel names.' ) ; } return $ channels ; } }
Validate a channel or set of channels, return JSON if appropriate.

@param array $channels
@param bool  $returnAsArray
@return array|string
@throws \Pushman\PHPLib\Exceptions\InvalidChannelException
Validate a channel or set of channels return JSON if appropriate .