Parse the field value

@return string
428225
protected function parseValue( array $args )
	{
		$default = $args['default'];
		$name    = $args['name'];
		$prefix  = $args['prefix'];
		$value   = $args['value'];

		if( $default == ':placeholder' ) {
			$default = '';
		}

		return ( !empty( $value ) || !$name || $prefix === false )
			? $value
			: $default;
	}
1317165
public function parse()
    {
        $bytes = (int) $this->data;
        if ($bytes < 0) {
            return null;
        }

        $bytes += 2; // CRLF
        $string = '';

        do {
            $buffer = $this->read($bytes);
            $string .= $buffer;
            $bytes -= strlen($buffer);
        } while ($bytes > 0);

        return substr($string, 0, -2); // Remove last CRLF
    }
458076
public function parse()
    {
        $newTokens = array();
        $len = count($this->tokens);
        $this->stack = array();
        $propValue = 'PROPERTY';
        $pushes = array(
            'L_BRACKET' => 'bracket',
            'L_BRACE' => 'brace',
            'AT_IDENTIFIER' => 'at',
            'L_SQ_BRACKET' => 'square'
        );
        $pops = array(
            'R_BRACKET' => 'bracket',
            'R_BRACE' => 'brace',
            'R_SQ_BRACKET' => 'square'
        );
        $this->index = 0;
        while ($this->index < $len) {
            $token = &$this->tokens[$this->index];
            $stackSize = count($this->stack);
            $state = !$stackSize? null : $this->stack[$stackSize - 1];
            $tokName = &$token[0];
            $inBrace = in_array('brace', $this->stack);
            $inBracket = in_array('bracket', $this->stack);
            $inSq = in_array('square', $this->stack);
            $inAt = in_array('at', $this->stack);
            if ($tokName === self::$deleteToken) {
                continue;
            }

            if ($tokName === 'L_BRACE') {
                if ($state === 'at') {
                    array_pop($this->stack);
                }
                $this->stack[] = $pushes[$tokName];
                $propValue = 'PROPERTY';
            } elseif (isset($pushes[$tokName])) {
                $this->stack[] = $pushes[$tokName];
            } elseif (isset($pops[$tokName]) && $state === $pops[$tokName]) {
                array_pop($this->stack);
            } elseif (!$inBracket && $tokName === 'COLON') {
                $propValue = 'VALUE';
            } elseif ($tokName === 'SEMICOLON') {
                $propValue = 'PROPERTY';
                if ($state === 'at') {
                    array_pop($this->stack);
                }
            } elseif ($tokName === 'GENERIC_IDENTIFIER') {
                // this is where the fun starts.
                // we have to figure out exactly what this is
                // if we can look ahead and find a '{' before we find a
                // ';', then this is part of a selector.
                // Otherwise it's part of a property/value pair.
                // the exception is when we have something like:
                // font : { family : sans-serif; }
                // then we need to check for ':{'
                if ($inSq) {
                    $token[0] = 'ATTR_SELECTOR';
                } elseif ($inBracket) {
                    $this->parseIdentifier($token);
                } elseif (!$inAt) {
                    $semi = $this->nextOfType('SEMICOLON');
                    $colonBrace = $this->nextSequence(array('COLON', 'L_BRACE'), array('WHITESPACE'));
                    $brace = $this->nextOfType('L_BRACE');

                    $ruleTerminator = min($semi, $colonBrace);
                    if ($brace < $ruleTerminator) {
                        $this->parseRule();
                        $propValue = 'PROPERTY';
                    } else {
                        $this->tokens[$this->index][0] = $propValue;
                        if ($propValue === 'VALUE') {
                            $this->parseIdentifier($token);
                        }
                    }
                }
            }
            $this->index++;
        }
        $this->cleanup();
    }
854284
public function parse()
    {
        if (empty($this->key) || strlen($this->key) < 10) {
            return $this->failed("Invalid SNDS key: {$this->key}");
        }

        if (!filter_var($this->url, FILTER_VALIDATE_URL) === true) {
            return $this->failed("Invalid URL configured: {$this->url}");
        }

        if (!$this->createWorkingDir()) {
            return $this->failed(
                "Unable to create working directory"
            );
        }
        $tempFile = "{$this->tempPath}/snds.csv";

        $client = new GuzzleHttp\Client();

        $res = $client->request(
            'GET',
            "{$this->url}?key={$this->key}",
            [
                'http_errors' => false,
                'save_to' => $tempFile
            ]
        );
        if ($res->getStatusCode() !== 200) {
            return $this->failed("URL collection from {$this->url} resulted in a {$res->getStatusCode()}");
        }

        $csvReports = new Reader\CsvReader(new SplFileObject($tempFile));
        $csvReports->setColumnHeaders(
            [
                'first_ip',
                'last_ip',
                'blocked',
                'feed',
            ]
        );


        foreach ($csvReports as $report) {
            $this->feedName = 'unknown';

            // If report type is an alias, get the real type
            foreach (config("{$this->configBase}.collector.aliasses") as $alias => $real) {
                if ($report['feed'] == $alias) {
                    $this->feedName = $real;
                }
            }

            if ($this->isKnownFeed() && $this->isEnabledFeed()) {

                $firstIP = inetPtoi($report['first_ip']);
                $lastIP = inetPtoi($report['last_ip']);

                if (!empty($firstIP) && !empty($lastIP) && $firstIP <= $lastIP) {
                    for ($x = $firstIP; $x <= $lastIP; $x++) {
                        $report['ip'] = inetItop($x);

                        if ($this->hasRequiredFields($report) === true) {
                            $report = $this->applyFilters($report);

                            $incident = new Incident();
                            $incident->source      = config("{$this->configBase}.collector.name");
                            $incident->source_id   = false;
                            $incident->ip          = $report['ip'];
                            $incident->domain      = false;
                            $incident->class       = config(
                                "{$this->configBase}.feeds.{$this->feedName}.class"
                            );
                            $incident->type        = config(
                                "{$this->configBase}.feeds.{$this->feedName}.type"
                            );
                            /*
                             * This prevents multiple incidents on the same day. So info
                             * blob has a scan time and this a report time
                             */
                            $incident->timestamp   = strtotime('0:00');
                            $incident->information = json_encode($report);

                            $this->incidents[] = $incident;
                        }
                    }
                }
            }
        }

        return $this->success();
    }
1248610
public function parse()
	{
		while (($this->position = strpos($this->data, '&', $this->position)) !== false)
		{
			$this->consume();
			$this->entity();
			$this->consumed = '';
		}
		return $this->data;
	}
360980
public function getValueList()
    {
        // add model data rows in value list
        try {
            if ($this->model) {
                $id = $this->model->id_field;
                $title = $this->model->getElement($this->model->title_field);

                $this->value_list = array();
                foreach ($this->model as $row) {
                    $this->value_list[(string) $row[$id]] = $row[$title];
                }
            }

            // prepend empty text message at the begining of value list if needed
            if ($this->empty_text && !isset($this->value_list[$this->empty_value])) {
                $this->value_list = array($this->empty_value => $this->empty_text) + $this->value_list;
            }

            return $this->value_list;
        } catch (\atk4\core\Exception $e) {
            $e->addMoreInfo('values_for_field', $this->short_name);
            throw $e;
        }
    }
757025
public function parse() : string
	{
		$raw_token = $this->_Request->getHeader($this->key);

		if(!$raw_token) {
			return '';
		}

		return trim( str_ireplace($this->prefix, '', $raw_token));
	}
680965
public function parseFields($fields)
    {
        switch (true) {
            case is_array($fields):
                $fields = array_values($fields);
                break;
            case is_string($fields):
                $fields = preg_split('/\s*,\s*/', trim($fields), -1, PREG_SPLIT_NO_EMPTY);
                break;
            default:
                throw new QueryException('', QueryException::SELECT_NOT_PARSE);
                break;
        }
        return $fields ? $fields :[];
    }
985598
public function parse()
    {
        $input = $this->queryString;

        // Parse string if it's not already parsed into an array
        if (is_string($this->queryString)) {
            $input = [];
            parse_str($this->queryString, $input);
        }

        $this->query = new Query($input);

        $this->parseQ();
        $this->parseEmbeds();
        $this->parseIncludes();
        $this->parseExcludes();
        $this->parseSorts();

        return $this->query;
    }
1168662
public function parseLimit()
	{
		if(!isset($this->operationOption['limit'],$this->operationOption['limit'][0]))
		{
			return '';
		}
		return 'limit ' . $this->operationOption['limit'][0] . (isset($this->operationOption['limit'][1]) ? (',' . $this->operationOption['limit'][1]) : '');
	}
264848
protected function parse()
    {
        if ($this->hasElement()) {
            return $this->getElement();
        }

        $stack = [];
        foreach ($this->stack as $offset => $where) {
            $stack[$offset] = $where->parse();
        }

        return sprintf('(%s)', join(sprintf(' %s ', $this->operator), $stack));
    }
536856
protected function parseQuotedAttributeValue()
	{
		$quote    = $this->text[$this->pos];
		$valuePos = $this->pos + 1;
		while (1)
		{
			// Look for the next quote
			$this->pos = strpos($this->text, $quote, $this->pos + 1);
			if ($this->pos === false)
			{
				// No matching quote. Apparently that string never ends...
				throw new RuntimeException;
			}

			// Test for an odd number of backslashes before this character
			$n = 0;
			do
			{
				++$n;
			}
			while ($this->text[$this->pos - $n] === '\\');

			if ($n % 2)
			{
				// If $n is odd, it means there's an even number of backslashes. We can exit this
				// loop
				break;
			}
		}

		// Unescape special characters ' " and \
		$attrValue = preg_replace(
			'#\\\\([\\\\\'"])#',
			'$1',
			substr($this->text, $valuePos, $this->pos - $valuePos)
		);

		// Skip past the closing quote
		++$this->pos;

		return $attrValue;
	}
1312490
private function parseArray()
    {
        $length = $this->parseUnsignedInt32();
        $stopAt = strlen($this->buffer) - $length;
        $array = [];

        while (strlen($this->buffer) > $stopAt) {
            $array[] = $this->parseField();
        }

        return $array;
    }
31621
public function parse()
    {
        if (isset($this->raw->data)) {
            $this->setData($this->raw->data);
        }

        if (isset($this->raw->included)) {
            $this->setIncluded($this->raw->included);
        }

        if (isset($this->raw->links)) {
            $this->setLinks($this->raw->links);
        }

        if (isset($this->raw->meta)) {
            $this->setMeta($this->raw->meta);
        }

        if (isset($this->raw->errors)) {
            $this->setErrors($this->raw->errors);
        }

        return $this;
    }
363201
public function parseLabel()
    {
        $token = '';

        /**
         * Value to be returned.
         *
         * @var Token
         */
        $ret = null;

        /**
         * The value of `$this->last` where `$token` ends in `$this->str`.
         *
         * @var int
         */
        $iEnd = $this->last;
        for ($j = 1; $j < Context::LABEL_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
            if ($this->str[$this->last] === ':' && $j > 1) {
                // End of label
                $token .= $this->str[$this->last];
                $ret = new Token($token, Token::TYPE_LABEL);
                $iEnd = $this->last;
                break;
            } elseif (Context::isWhitespace($this->str[$this->last]) && $j > 1) {
                // Whitespace between label and :
                // The size of the keyword didn't increase.
                --$j;
            } elseif (Context::isSeparator($this->str[$this->last])) {
                // Any other separator
                break;
            }
            $token .= $this->str[$this->last];
        }

        $this->last = $iEnd;

        return $ret;
    }
392446
protected function parse()
    {
        $sectionName = static::GLOBAL_SECTION;
        $values = [];

        try {
            while ($line = fgets($this->handle)) {
                $this->linenumber++;
                $line = trim($line);
                if (empty($line) || substr($line, 0, 1) === ';') {
                    continue;
                }

                if ($this->isSectionHeader($line)) {
                    if ($sectionName === static::GLOBAL_SECTION) {
                        $this->config = $values;
                    } else {
                        $tokens = explode($this->delimiter, $sectionName);
                        $this->config = array_merge_recursive($this->config,
                                                              $this->subdivide($tokens, $values));

                        unset($tokens);
                    }

                    $sectionName = $this->getSectionHeader($line);
                    $values = [];
                    continue;
                }

                list($key, $value) = array_pad(preg_split(static::SPLIT_PATTERN, trim($line), 2), 2, '');

                if ($this->isArrayKey($key)) {
                    if (is_null($array_key = $this->parseArrayKey($key))) {
                        $key = trim(trim($key), '[]');

                        $values[$key][] = $this->parseValue($value);
                    } else {
                        $key = trim(substr($key, 0, strpos($key, '[')));
                        if (!isset($values[$key])) {
                            $values[$key] = [];
                        }

                        $values[$key][$array_key] = $this->parseValue($value);
                    }
                } else {
                    $values[trim($key)] = $this->parseValue($value);
                }
            }
        } catch (\Exception $ex) {
            throw new \RuntimeException("{$ex->getMessage()} Line: {$this->linenumber}.");
        } finally {
            $this->close();
        }

        if ($sectionName === static::GLOBAL_SECTION) {
            $this->config = $values;
        } else {
            $section = $this->subdivide(explode($this->delimiter, $sectionName), $values);
            $this->config = array_merge($this->config, $section);
        }
    }
980698
protected function parseSearch()
    {
        return implode(' ', array_map(function ($key, $val) {
            if (is_null($val)) {
                return strtoupper($key);
            }
            return sprintf('%s %s', strtoupper($key), $val);
        }, array_keys($this->where), array_values($this->where)));
    }