@param string $name
@param string $value
@param string $documentName
@param string $format

@return array
548589
public function generateFilter($name, $value, $documentName='', $format='')
    {
        $value = preg_quote($value);
        $filter = array($name => new MongoRegex('/.*'.$value.'.*/i'));

        return $filter;
    }
112429
public function getHeaders($filename, $format = self::FORMAT_GUZZLE) {

        $rawHeaders = $this->getFile($filename);

        preg_match_all('/(.+):\ (.+)/i', $rawHeaders, $matches);

        // Curl format
        if($format == self::FORMAT_CURL) return $matches[0];

        // Guzzle format
        $headers = array();

        foreach($matches[0] as $i => $matche) {
            $headers[$matches[1][$i]] = $matches[2][$i];
        }

        return $headers;
    }
255938
public function getSymbol($name, $value=null, $verbosity = FormatterContract::SHORT)
    {
        $key = $this->getSymbolKey($name, $value, $verbosity);

        if (!isset($this->formatCache[$key])) {
            $this->formatCache[$key] = $this->loadFormat($key);
        }

        if ($name == self::WEEKDAY || $name == self::MONTH) {
            $this->dateFormatCache = [];
        }

        return $this->formatCache[$key];
    }
478684
public function get($name)
    {
        static $formats = [
            // @property int
            'year' => 'Y',
            // @property int
            'yearIso' => 'o',
            // @property int
            // @call isSameUnit
            'month' => 'n',
            // @property int
            'day' => 'j',
            // @property int
            'hour' => 'G',
            // @property int
            'minute' => 'i',
            // @property int
            'second' => 's',
            // @property int
            'micro' => 'u',
            // @property int
            'microsecond' => 'u',
            // @property-read int 0 (for Sunday) through 6 (for Saturday)
            'dayOfWeek' => 'w',
            // @property-read int 1 (for Monday) through 7 (for Sunday)
            'dayOfWeekIso' => 'N',
            // @property-read int ISO-8601 week number of year, weeks starting on Monday
            'weekOfYear' => 'W',
            // @property-read int number of days in the given month
            'daysInMonth' => 't',
            // @property int seconds since the Unix Epoch
            'timestamp' => 'U',
            // @property-read string "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark)
            'latinMeridiem' => 'a',
            // @property-read string "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark)
            'latinUpperMeridiem' => 'A',
            // @property string the day of week in English
            'englishDayOfWeek' => 'l',
            // @property string the abbreviated day of week in English
            'shortEnglishDayOfWeek' => 'D',
            // @property string the day of week in English
            'englishMonth' => 'F',
            // @property string the abbreviated day of week in English
            'shortEnglishMonth' => 'M',
            // @property string the day of week in current locale LC_TIME
            'localeDayOfWeek' => '%A',
            // @property string the abbreviated day of week in current locale LC_TIME
            'shortLocaleDayOfWeek' => '%a',
            // @property string the month in current locale LC_TIME
            'localeMonth' => '%B',
            // @property string the abbreviated month in current locale LC_TIME
            'shortLocaleMonth' => '%b',
        ];

        switch (true) {
            case isset($formats[$name]):
                $format = $formats[$name];
                $method = substr($format, 0, 1) === '%' ? 'formatLocalized' : 'rawFormat';
                $value = $this->$method($format);

                return is_numeric($value) ? (int) $value : $value;

            // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language
            case $name === 'dayName':
                return $this->getTranslatedDayName();
            // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language
            case $name === 'shortDayName':
                return $this->getTranslatedShortDayName();
            // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language
            case $name === 'minDayName':
                return $this->getTranslatedMinDayName();
            // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language
            case $name === 'monthName':
                return $this->getTranslatedMonthName();
            // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language
            case $name === 'shortMonthName':
                return $this->getTranslatedShortMonthName();
            // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
            case $name === 'meridiem':
                return $this->meridiem(true);
            // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language
            case $name === 'upperMeridiem':
                return $this->meridiem();
            // @property-read int current hour from 1 to 24
            case $name === 'noZeroHour':
                return $this->hour ?: 24;
            // @property int
            case $name === 'milliseconds':
                // @property int
            case $name === 'millisecond':
            // @property int
            case $name === 'milli':
                return (int) floor($this->rawFormat('u') / 1000);

            // @property int 1 through 53
            case $name === 'week':
                return (int) $this->week();

            // @property int 1 through 53
            case $name === 'isoWeek':
                return (int) $this->isoWeek();

            // @property int year according to week format
            case $name === 'weekYear':
                return (int) $this->weekYear();

            // @property int year according to ISO week format
            case $name === 'isoWeekYear':
                return (int) $this->isoWeekYear();

            // @property-read int 51 through 53
            case $name === 'weeksInYear':
                return (int) $this->weeksInYear();

            // @property-read int 51 through 53
            case $name === 'isoWeeksInYear':
                return (int) $this->isoWeeksInYear();

            // @property-read int 1 through 5
            case $name === 'weekOfMonth':
                return (int) ceil($this->day / static::DAYS_PER_WEEK);

            // @property-read int 1 through 5
            case $name === 'weekNumberInMonth':
                return (int) ceil(($this->day + $this->copy()->startOfMonth()->dayOfWeekIso - 1) / static::DAYS_PER_WEEK);

            // @property-read int 0 through 6
            case $name === 'firstWeekDay':
                return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt();

            // @property-read int 0 through 6
            case $name === 'lastWeekDay':
                return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK - 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt();

            // @property int 1 through 366
            case $name === 'dayOfYear':
                return 1 + intval($this->rawFormat('z'));

            // @property-read int 365 or 366
            case $name === 'daysInYear':
                return $this->isLeapYear() ? 366 : 365;

            // @property int does a diffInYears() with default parameters
            case $name === 'age':
                return $this->diffInYears();

            // @property-read int the quarter of this instance, 1 - 4
            // @call isSameUnit
            case $name === 'quarter':
                return (int) ceil($this->month / static::MONTHS_PER_QUARTER);

            // @property-read int the decade of this instance
            // @call isSameUnit
            case $name === 'decade':
                return (int) ceil($this->year / static::YEARS_PER_DECADE);

            // @property-read int the century of this instance
            // @call isSameUnit
            case $name === 'century':
                $factor = 1;
                $year = $this->year;
                if ($year < 0) {
                    $year = -$year;
                    $factor = -1;
                }

                return (int) ($factor * ceil($year / static::YEARS_PER_CENTURY));

            // @property-read int the millennium of this instance
            // @call isSameUnit
            case $name === 'millennium':
                $factor = 1;
                $year = $this->year;
                if ($year < 0) {
                    $year = -$year;
                    $factor = -1;
                }

                return (int) ($factor * ceil($year / static::YEARS_PER_MILLENNIUM));

            // @property int the timezone offset in seconds from UTC
            case $name === 'offset':
                return $this->getOffset();

            // @property int the timezone offset in minutes from UTC
            case $name === 'offsetMinutes':
                return $this->getOffset() / static::SECONDS_PER_MINUTE;

            // @property int the timezone offset in hours from UTC
            case $name === 'offsetHours':
                return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR;

            // @property-read bool daylight savings time indicator, true if DST, false otherwise
            case $name === 'dst':
                return $this->rawFormat('I') === '1';

            // @property-read bool checks if the timezone is local, true if local, false otherwise
            case $name === 'local':
                return $this->getOffset() === $this->copy()->setTimezone(date_default_timezone_get())->getOffset();

            // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise
            case $name === 'utc':
                return $this->getOffset() === 0;

            // @property CarbonTimeZone $timezone the current timezone
            // @property CarbonTimeZone $tz alias of $timezone
            case $name === 'timezone' || $name === 'tz':
                return CarbonTimeZone::instance($this->getTimezone());

            // @property-read string $timezoneName the current timezone name
            // @property-read string $tzName alias of $timezoneName
            case $name === 'timezoneName' || $name === 'tzName':
                return $this->getTimezone()->getName();

            // @property-read string $timezoneAbbreviatedName the current timezone abbreviated name
            // @property-read string $tzAbbrName alias of $timezoneAbbreviatedName
            case $name === 'timezoneAbbreviatedName' || $name === 'tzAbbrName':
                return CarbonTimeZone::instance($this->getTimezone())->getAbbr($this->dst);

            // @property-read string locale of the current instance
            case $name === 'locale':
                return $this->getLocalTranslator()->getLocale();

            default:
                if (static::hasMacro($macro = 'get'.ucfirst($name))) {
                    return $this->$macro();
                }

                throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name));
        }
    }
942275
public function make(string $name = null, string $value = null): \BearFramework\App\Request\FormDataItem
    {
        if ($this->newFormDataItemCache === null) {
            $this->newFormDataItemCache = new \BearFramework\App\Request\FormDataItem();
        }
        $object = clone($this->newFormDataItemCache);
        if ($name !== null) {
            $object->name = $name;
        }
        if ($value !== null) {
            $object->value = $value;
        }
        return $object;
    }
1043121
public function find($documentName, $hashValue, $rangeValue = null)
    {
        return $this->getRepository($documentName)->find($hashValue, $rangeValue);
    }
968519
public function encode($value, $name)
    {
        if ($this->isDynamicArray($name)) {
            $length = count($value);
            $nestedName = $this->nestedName($name);
            $result = [];
            $result[] = IntegerFormatter::format($length);

            foreach ($value as $val) {
                $result[] = $this->encode($val, $nestedName);
            }
            return $result;
        } elseif ($this->isStaticArray($name)) {
            $length = $this->staticArrayLength($name);
            $nestedName = $this->nestedName($name);
            $result = [];

            foreach ($value as $val) {
                $result[] = $this->encode($val, $nestedName);
            }
            return $result;
        }
        return $this->inputFormat($value, $name);
    }
940857
public function getFormat($name, $filePath, $mode) {
        $formats = $this->getFormats();
        if (!isset($formats[$name])) {
            throw new Exception("Format `$name` is not registered");
        }
        if (!is_callable($formats[$name])) {
            throw new Exception("Cannot generate format `$name`");
        }
        $format = call_user_func($formats[$name], $filePath, $mode);
        if (!$format instanceof Format) {
            throw new Exception("Cannot generate format `$name`");
        }
        return $format;
    }
775199
public function field(string $name, Syntax $value = null)
    {
        if ($value === null) {
            $names = explode('.', $name);
            $syntax = $this;
            foreach ($names as $field) {
                while (method_exists($syntax, 'syntax')) {
                    $syntax = $syntax->syntax();
                }
                if ($syntax instanceof ObjectSyntax && array_key_exists($field, $syntax->fields)) {
                    $syntax = $syntax->fields[$field];
                } else {
                    throw new \InvalidArgumentException("field '{$name}' not found");
                }
            }
            return $syntax;
        }

        $this->fields[$name] = $value;
        return $this;
    }
1258650
private function createNumberNode(\DOMDocument $document, $value, string $name = null): \DOMNode
    {
        $node = $document->createElement('json:number', (string) $value);

        if (null !== $name) {
            $node->setAttribute('name', $name);
        }

        return $node;
    }
155150
protected function normalizeProperty($value, $name, $format = null, array $context = array())
    {
        /** @var ClassMetadata $meta */
        $meta = $context['entityMeta'];

        if ($meta->hasField($name)) {
            return $value;
        }

        if (isset($meta->embeddedClasses[$name])) {
            return parent::normalize($value, $format, $context);
        }

        switch ($meta->associationMappings[$name]['type']) {
            case ClassMetadata::ONE_TO_ONE:
            case ClassMetadata::MANY_TO_ONE:
                return $this->normalizeAssociation($value, $name, $format, $context);

            case ClassMetadata::ONE_TO_MANY:
            case ClassMetadata::MANY_TO_MANY:
                return $this->normalizeCollection($value, $name, $format, $context);
        }
    }
1296392
private function sanitiseVariableName(string $name, $value): array
    {
        $name = trim(str_replace(['export ', '\'', '"'], '', $name));

        return [$name, $value];
    }
129447
public function getResponse($format, $filename, SourceIteratorInterface $source)
    {
        switch ($format) {
            case 'xls':
                $writer = new XlsWriter('php://output');
                $contentType = 'application/vnd.ms-excel';

                break;
            case 'xml':
                $writer = new XmlWriter('php://output');
                $contentType = 'text/xml';

                break;
            case 'json':
                $writer = new JsonWriter('php://output');
                $contentType = 'application/json';

                break;
            case 'csv':
                $writer = new CsvWriter('php://output', ',', '"', '\\', true, true);
                $contentType = 'text/csv';

                break;
            default:
                throw new \RuntimeException('Invalid format');
        }

        $callback = static function () use ($source, $writer) {
            $handler = Handler::create($source, $writer);
            $handler->export();
        };

        return new StreamedResponse($callback, 200, [
            'Content-Type' => $contentType,
            'Content-Disposition' => sprintf('attachment; filename="%s"', $filename),
        ]);
    }
83533
public static function string($value, $format = null)
    {
        if (is_null($format)) {
            $format = '%s';
        }

        return sprintf($format, $value);
    }
268558
protected function getValueArray($name, $value = null)
    {
        // Looks for the values in "old"
        if (!$this->oldInputIsEmpty()) {
            if (is_null($this->session->getOldInput($name))) { // we have old input, but none for this name
                return [];
            } else {
                return $this->session->getOldInput($name);
            }
        }
        // Looks for the values in the Request
        if (isset($this->request) and $this->request->input($name)) {
            return $this->request->input($name);
        }
        // Returns the default value
        return empty($value) ? [] : $value;
    }
19002
public static function attr($name, $value = null)
    {
        if (is_string($name)) {
            $name = [$name => $value];
        }

        return HtmlBuilder::buildAttributes($name);
    }
403440
protected function formatValue($format, $value)
    {
        switch ($format) {
            case 'dash':
                return $this->inflector->dasherize($value);
            case 'underscore':
                return $this->inflector->underscore($value);
            case 'studlycaps':
                return $this->inflector->studlify($value);
            case 'camelcase':
                return $this->inflector->camelize($value);
            default:
                throw new RuntimeException('Unable to format value');
        }
    }