/**
  * Instantiates an object using a string formatted according to the Google
  * Analytics API's syntax.
  *
  * @param string $filters
  * @return Google\Analytics\GaDataFilterCollection
  */
 public static function createFromString($filters)
 {
     $andFilters = \PFXUtils::explodeUnescaped(self::OP_AND, $filters);
     $andCollections = array();
     $reflector = new \ReflectionClass(__CLASS__);
     foreach ($andFilters as $andFilter) {
         $orFilters = \PFXUtils::explodeUnescaped(self::OP_OR, $andFilter);
         $orFilterInstances = array();
         foreach ($orFilters as $orFilter) {
             $orFilterInstances[] = new GaDataConditionalExpression($orFilter);
         }
         $andCollections[] = $reflector->newInstanceArgs(array_merge(array(self::OP_OR), $orFilterInstances));
     }
     return $reflector->newInstanceArgs(array_merge(array(self::OP_AND), $andCollections));
 }
    /**
     * Tests PFXUtils::explodeUnescaped().
     */
    public function testExplodeUnescaped()
    {
        $str = 'foo;bar\\;baz;boo';
        $expected = array('foo', 'bar\\;baz', 'boo');
        $this->assertEquals($expected, PFXUtils::explodeUnescaped(';', $str));
        // We can use a different escape character
        $str = <<<EOF
   some -guy
wants toghit me. What the heck is that about?g.
EOF;
        $expected = array("   some -guy\nwants to", 'hit me. What the heck is that about?', '.');
        $this->assertEquals($expected, PFXUtils::explodeUnescaped('g', $str, '-'));
    }
 /**
  * Parses a sequence condition into its component pieces.
  *
  * @param string $str
  */
 protected function _setPropertiesFromString($str)
 {
     /* This isn't quite as slick as the approach that
     		Google\Analytics\GaDataConditionalExpression uses to find the operator,
     		but it does ensure that we only match the correct operators, and it's
     		unlikely this will need much (if any) maintenance in the future. */
     $operators = array(self::OP_FOLLOWED_BY, self::OP_FOLLOWED_BY_IMMEDIATE, self::OP_FIRST_HIT_MATCHES_FIRST_STEP);
     foreach ($operators as $operator) {
         $len = strlen($operator);
         if (substr($str, 0, $len) == $operator) {
             $this->_constraintAgainstPrevious = $operator;
             $str = substr($str, $len);
             break;
         }
     }
     // See if there were any additional conditions
     $conditions = \PFXUtils::explodeUnescaped(GaDataLogicalCollection::OP_AND, $str);
     $str = array_shift($conditions);
     foreach ($conditions as $condition) {
         $this->addCondition(new GaDataSegmentSimpleCondition($condition));
     }
     parent::_setPropertiesFromString($str);
 }