Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 
<?php
namespace Apptus\ESales\Connector;

use Apptus\ESales\Connector\Filters\AtomFilter;

/**
 * Represents a filter for a query.
 *
 * @see FilterBuilder
 */
abstract class Filter {
    public final function __toString() {
        return $this->buildFilterString();
    }

    /**
     * @internal
     */
    abstract protected function buildFilterString();

    /**
     * @internal
     */
    protected function isAtom() {
        return ($this instanceof AtomFilter);
    }

    /**
     * @internal
     */
    protected static function buildValue($value) {
        if ($value === null) {
            return '\'\'';
        }
        return '\'' . self::escapeValue($value) . '\'';
    }

    /**
     * @internal
     */
    private static function escapeValue($value) {
        return str_replace(array ('\\', '\''), array ('\\\\', '\\\''), $value);
    }

    /**
     * @internal
     */
    protected static function buildAttributes($attributes, $incremental) {
        $str = implode(',', array_map('\Apptus\ESales\Connector\Filter::escapeAttribute', $attributes));
        return $str . ($incremental ? '*:' : ':');
    }

    /**
     * @internal
     */
    private static function escapeAttribute($attribute) {
        return str_replace(array ('\\', ',', ':'), array ('\\\\', '\\,', '\\:'), $attribute);
    }
}
Apptus ESales Connector PHP API documentation generated by ApiGen