Rewrites Blade "for else" statements into valid PHP.

@param  string  $value
@return string
196569
protected static function compile_forelse($value)
	{
		preg_match_all('/(\s*)@forelse(\s*\(.*\))(\s*)/', $value, $matches);

		foreach ($matches[0] as $forelse)
		{
			preg_match('/\s*\(\s*(\S*)\s/', $forelse, $variable);

			// Once we have extracted the variable being looped against, we can add
			// an if statement to the start of the loop that checks if the count
			// of the variable being looped against is greater than zero.
			$if = "<?php if (count({$variable[1]}) > 0): ?>";

			$search = '/(\s*)@forelse(\s*\(.*\))/';

			$replace = '$1'.$if.'<?php foreach$2: ?>';

			$blade = preg_replace($search, $replace, $forelse);

			// Finally, once we have the check prepended to the loop we'll replace
			// all instances of this forelse syntax in the view content of the
			// view being compiled to Blade syntax with real PHP syntax.
			$value = str_replace($forelse, $blade, $value);
		}

		return $value;
	}
370668
protected function _validate_url($value)
    {
        if ($value === '') {
            return '';
        }

        if (strpos($value, '://') === false) {
            $value = 'http://' . $value;
        }

        return filter_var($value, FILTER_VALIDATE_URL) !== false ? $value : null;
    }
827080
private function formatValue($value)
    {
        if ($value === '') {
            return '';
        }

        if ($value === null) {
            return '<comment>Null</comment>';
        }

        if (is_bool($value)) {
            return '<comment>' . ($value ? 'True' : 'False') . '</comment>';
        }

        if (empty($value)) {
            return '<comment>Empty</comment>';
        }

        if (is_array($value)) {
            return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
        }

        if (is_object($value)) {
            return sprintf('<%s>', get_class($value));
        }

        if (is_scalar($value)) {
            return $value;
        }

        throw new InvalidArgumentException(sprintf('Do not know how to format value "%s"', print_r($value, true)));
    }
1237514
public function compileString( $value )
	{
		$result = '';

		if ( strpos( $value, '@verbatim' ) !== false )
		{
			$value = $this->storeVerbatimBlocks( $value );
		}

		$this->footer = [];

		// Here we will loop through all of the tokens returned by the Zend lexer and
		// parse each one into the corresponding valid PHP. We will then have this
		// template as the correctly rendered PHP that can be rendered natively.
		foreach ( token_get_all( $value ) as $token )
		{
			$result .= is_array( $token ) ? $this->parseToken( $token ) : $token;
		}

		if ( !empty( $this->verbatimBlocks ) )
		{
			$result = $this->restoreVerbatimBlocks( $result );
		}

		// If there are any footer lines that need to get added to a template we will
		// add them here at the end of the template. This gets used mainly for the
		// template inheritance via the extends keyword that should be appended.
		if ( count( $this->footer ) > 0 )
		{
			$result = ltrim( $result, PHP_EOL ) . PHP_EOL . implode( PHP_EOL, array_reverse( $this->footer ) );
		}

		return $result;
	}
133458
protected function processScalarValue($value)/*# : string */
    {
        if (ClauseInterface::NO_VALUE == $value) {
            return '?';
        } elseif (is_null($value) || is_bool($value)) {
            return strtoupper(var_export($value, true));
        } else {
            return $this->getBuilder()->getParameter()->getPlaceholder($value);
        }
    }
428167
protected function prepareValue($value)
    {
        $params = $this->getOperatorParams();
        $method = $params['method'];
        switch ($method) {
            case 'where':
            case 'whereNull':
            case 'whereNotNull':
                break;
            case 'whereBetween':
            case 'whereNotBetween':
                if (! is_array($value)) {
                    $value = explode(',', $value, 2);
                }
                break;
            case 'whereIn':
            case 'whereNotIn':
                if (! is_array($value)) {
                    $value = explode(',', $value);
                }
                break;
        }

        return $value;
    }
479456
protected function _compileEscapedEchos($value)
    {
        $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->_escapedTags[0], $this->_escapedTags[1]);

        $callback = function ($matches) {
            if ($matches[1]) {
                return substr($matches[0], 1);
            }

            if (preg_match('#^[\w\.\[\]"\']+$#', $matches[2]) || preg_match('#^\\$[\w]+\(#', $matches[2])) {
                return $matches[0];
            } elseif ($this->_isSafeEchos($matches[2])) {
                return "<?= $matches[2] ?>" . (empty($matches[3]) ? '' : $matches[3]);
            } else {
                return '<?= e(' . $this->_compileEchoDefaults($matches[2]) . '); ?>' . (empty($matches[3]) ? '' : $matches[3]);
            }
        };

        return preg_replace_callback($pattern, $callback, $value);
    }
1151782
public static function toBool($value)
    {
        if ($value instanceof Countable) {
            return (bool)count($value);
        }

        if (!static::isStringLike($value)) {
            return (bool)$value;
        }

        $string = "$value";

        if (trim($string) == '') {
            return false;
        }

        if (in_array(strtolower($value), ['0', 'false'], true)) {
            return false;
        }

        return (bool)$string;

    }
476636
protected static function formatValue($value)
    {
        if ($value instanceof \DateTime) {
            $value = $value->format(\DateTime::ISO8601);
        } elseif (\is_bool($value)) {
            $value = $value ? 'True' : 'False';
        } elseif (\is_array($value) || $value instanceof \IteratorAggregate) {
            $itValue = $value instanceof \IteratorAggregate ? $value->getIterator() : $value;
            $value = [];
            foreach ($itValue as $key => $arrayValue) {
                $value[$key] = static::formatValue($arrayValue);
            }
            $value = implode("\n  ", $value);
        }

        return (string) $value;
    }
1072529
protected function _cleanValue($value, $trim = false)
    {
        $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
        return ($trim) ? trim($value) : $value;
    }
1205081
public static function convertDashToCamelCase ($value)
    {
        $Filter = new \Zend\Filter\Word\DashToCamelCase();
        return $Filter->filter($value);
    }
407307
public function filter($value)
    {
        $chars = ' ';
        if ($this->getExtras()) {
            $chars .= $this->getExtras();
        }
        return trim($value, $chars);
    }
1328429
public function prepareValue($value)
    {
        return $value === null ? null : Carbon::createFromFormat($this->format, $value)->toDateString();
    }
765776
protected static function prepareNumericCast($value)
    {
        if (!in_array(gettype($value), static::$numericCastable, true)) {
            return '';
        }
        if (is_string($value)) {
            return trim($value);
        }
        return $value;
    }
1020798
public function compileMinify($value)
    {
        if ($this->ignoredPaths) {
            $path = str_replace('\\', '/', $this->getPath());

            foreach ($this->ignoredPaths as $ignoredPath) {
                if (strpos($path, $ignoredPath) !== false) {
                    return $value;
                }
            }
        }

        return $this->blade->render($value);
    }
1311316
protected function normalizeValue($value)
    {
        if (is_array($value)) {
            return implode(',', $value);
        } elseif (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        return $value;
    }
488718
protected function cleanupParam($value)
    {
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                $clean = $this->cleanupParam($v);
                if (!is_null($clean)) {
                    $value[$k] = $clean;
                }
            }

            return $value;
        } else {
            return preg_replace('/>/', '', preg_replace('/</', '', $value));
        }
    }