Format::apply

@return string
9856
public function apply()
    {
        if (empty($this->string)) {
            return '';
        }

        $lines = explode("\n", $this->string);

        foreach ($lines as &$line) {
            $line = ((string)$this->quote)
                . $line;
        }

        if ($this->color instanceof Color) {
            $output = str_repeat(' ', $this->indent) . $this->color->paint(implode("\n",
                    $lines)) . str_repeat(' ', $this->space);
        } else {
            $output = str_repeat(' ', $this->indent) . implode("\n", $lines) . str_repeat(' ', $this->space);
        }

        return str_repeat(PHP_EOL, $this->newLinesBefore) . $output . str_repeat(PHP_EOL, $this->newLinesAfter);
    }
563505
protected function runFormatters($e)
    {
        if ($e instanceof ErrorException) {
            $severity = $e->getSeverity();
        } else {
            $severity = E_ERROR;
        }

        /** @var \League\BooBoo\Formatter\FormatterInterface $formatter */
        foreach (array_reverse($this->formatterStack) as $formatter) {
            if ($severity & $formatter->getErrorLimit()) {
                return $formatter->format($e);
            }
        }
    }
54817
protected function applyPrefix()
    {
        if (is_callable($this->prefix)) {
            $prefix = call_user_func($this->prefix, $this);
        } else {
            $prefix = $this->prefix;
        }
        if ($prefix && strpos($this->_slug, $prefix) === false) {
            $this->_slug = $prefix . $this->_slug;
        }
    }
930131
public function compile()
    {
        preg_match_all('#{(.*?)}#i', $this->format, $out);

        $compiled = $this->format;

        foreach ($out[0] as $i => $var) {
            $format = '(?P<%s>%s)%s';
            $name   = str_replace('?', '', $out[1][$i]);
            $regex  = $this->getWhere($name) ?: '.*';
            $opt    = '';

            if (substr($var, -2, 1) == '?') {
                $opt = '?';
                $compiled = str_replace('/'.$var, '/?'.$var, $compiled);
            }

            $compiled = str_replace($var, sprintf($format, $name, $regex, $opt), $compiled);
        }

        return $compiled;
    }
815975
protected function getFormatter()
    {
        $formatter = new \NumberFormatter($this->locale, \NumberFormatter::DECIMAL);
        $precision = $this->field->getOption('precision', 0);

        if ($precision) {
            $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $precision);
        }

        return $formatter;
    }
860836
public function formatSimple()
    {
        return number_format(
            $this->getValue(),
            $this->currency->getPrecision(),
            $this->currency->getDecimalMark(),
            $this->currency->getThousandsSeparator()
        );
    }
906909
public function getFormat()
    {
        if ($this->_format === null) {
            $this->_format = $this->defaultFormat();
        }
        return $this->_format;
    }
664682
protected function acceptableFormatted()
    {
        if (!is_array($this->acceptable)) {
            return '';
        }

        $acceptable = array_map([$this, 'acceptableItemFormatted'], $this->acceptable);

        return '[' . implode('/', $acceptable) . ']';
    }
521400
public function apply()
    {
        if ( method_exists( $this->view, 'plugin' ) )
        {
            $global     = false;
            $roots      = (array) $this->roots;
            $headLink   = $this->getHeadLinkHelper();

            if ( in_array( null, $roots ) )
            {
                $global = true;
            }

            $roots = array_filter( $roots );

            if ( $global )
            {
                $roots[] = null;
            }

            $find       = array();
            $urls       = array();
            $preview    = false;

            foreach ( $roots as $root )
            {
                if ( $this->cssPreview->hasPreviewById( $root ) )
                {
                    $urls[$root] = $this->cssPreview
                                        ->getPreviewById( $root );
                }

                if ( empty( $urls[$root] ) )
                {
                    $find[] = $root;
                }
                else
                {
                    $preview = true;
                }
            }

            if ( ! empty( $find ) )
            {
                $url        = $this->getUrlHelper();
                $siteInfo   = $this->getSiteInfo();
                $schema     = $siteInfo->getSchema();
                $updated    = $this->extraModel
                                   ->findUpdated( $find );

                foreach ( $find as $root )
                {
                    if ( isset( $updated[$root] ) )
                    {
                        $urls[$root] = $url( 'Grid\Customize\Render\CustomCss', array(
                            'schema'    => $schema,
                            'id'        => $root ? (int) $root : 'global',
                            'hash'      => $updated[$root]->toHash(),
                        ) );
                    }
                }
            }

            foreach ( $roots as $root )
            {
                if ( ! empty( $urls[$root] ) )
                {
                    $id = $root ? (int) $root : 'global';

                    $headLink->prependStylesheet(
                        $urls[$root],
                        'all',
                        false,
                        array(
                            'class'             => 'customize-stylesheet',
                            'data-customize'    => $id,
                        )
                    );
                }
            }

            if ( $preview )
            {
                if ( empty( $url ) )
                {
                    $url = $this->getUrlHelper();
                }

                $translate = $this->getTranslateHelper();

                $this->getMessengerHelper()
                     ->add(
                         sprintf(
                             $translate(
                                 'customize.preview.applied.reset-link.%s',
                                 'customize'
                             ),
                             $url( 'Grid\Customize\CssAdmin\ResetPreviews', array(
                                 'locale' => \Locale::getDefault(),
                             ) )
                         ),
                         false,
                         Message::LEVEL_WARN
                     );
            }

            $this->roots = array();
        }

        return $this;
    }
145969
private static function format() {

		$routes = static :: getRoutes();

		foreach($routes as $identifier => $route) {

			$url = preg_quote($route -> getUrl(), '/'); 

			//Prepend prefix for url
			if($prefix = $route -> getPrefix()) {
				$url = $prefix['url'] . $url;
			}

			if(preg_match_all('#(\\\/)*\\\{([a-zA-Z0-9_.]+)(\\\\\?)?\\\}#i', $url, $matches)) {
				
				foreach($matches[0] as $index => $match) {

					$match 		= $matches[0][$index];
					$slash 		= $matches[1][$index];
					$type 		= $matches[2][$index];
					$optional 	= $matches[3][$index];
					$where 		= $route -> getWhere();
					$variable 	= '';
					$typefound 	= false;

					if('' !== $slash) {
						$variable .= '\/';
					}

					if(true === is_array($where)) {
						
						foreach($where as $key => $regex) {
							
							if($key === $type) {
								
								$variable .= $regex;
								$typefound = true;
								break;
							}
						}
					}

					if(false === $typefound) {

						if(isset(static :: $types[$type])) {
							$variable .= static :: $types[$type];
						}
						else {
							$variable .= static :: $types['string'];	
						}
					}

					if('' !== $optional) {
						$variable = '('. $variable .')?';
					}
					else {
						$variable = '('. $variable .')';
					}
					
					$url = preg_replace('#' . preg_quote($match, '/') . '#', $variable, $url, 1);
				}
			}

			$route -> setMatch($url);
		}
	}
632906
public function format(Collection $replacement)
    {
        $replacement = $this->prepare($replacement);
        $messageLines = explode(PHP_EOL, $replacement['message']);
        
        foreach ($messageLines as &$messageLine) {
            $replacement['message'] = $messageLine;
            $messageLine = $this->replace($this->getFormat(), $replacement);
        }
        
        return implode(PHP_EOL, $messageLines);
    }
1275700
public function apply()
    {
        $this->replacingLines = array();
        $this->init();
        if ($this->checkPreconditions()) {
            return $this->execute();
        } else {
            if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed])) {
                $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= ', ';
            } else {
                $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] = '';
            }
            $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= $this->getName();
            return false;
        }
    }
142504
public function apply()
    {
        $input = $this->grid->getInputProcessor()->getInput();
        $sort = null;
        if (isset($input['sort'])) {
            foreach ($input['sort'] as $field => $direction) {
                $sort = [$field, $direction];
                break;
            }
        }
        foreach ($this->grid->getConfig()->getColumns() as $column) {
            if ($sort) {
                if ($column->getName() === $sort[0]) {
                    $column->setSorting($sort[1]);
                } else {
                    $column->setSorting(null);
                }
            } else {
                if ($direction = $column->getSorting()) {
                    $sort = [$column->getName(), $direction];
                }
            }
        }
        if ($sort) {
            $this
                ->grid
                ->getConfig()
                ->getDataProvider()
                ->orderBy($sort[0], $sort[1]);
        }
    }
97468
public function applyComplement()
	{
		$length = strlen($this->data);

		for ($index = 0; $index < $length; $index++)
		{
			$this->data[$index] = chr(~ ord($this->data[$index]));
		}

		return $this->restrict();
	}
1000363
public function format()
    {
        return array_merge($this->options, [
            'data'  => $this->values,
            'label' => $this->name,
            'type'  => $this->type,
        ]);
    }
1271854
public function apply()
	{
		foreach ($this->patches as $patch)
		{
			// Separate the input into lines
			$lines = self::splitLines($patch['udiff']);

			// Loop for each header
			while (self::findHeader($lines, $src, $dst))
			{
				$done = false;

				if ($patch['strip'] === null)
				{
					$src = $patch['root'] . preg_replace('#^([^/]*/)*#', '', $src);
					$dst = $patch['root'] . preg_replace('#^([^/]*/)*#', '', $dst);
				}
				else
				{
					$src = $patch['root'] . preg_replace('#^([^/]*/){' . (int) $patch['strip'] . '}#', '', $src);
					$dst = $patch['root'] . preg_replace('#^([^/]*/){' . (int) $patch['strip'] . '}#', '', $dst);
				}

				// Loop for each hunk of differences
				while (self::findHunk($lines, $src_line, $src_size, $dst_line, $dst_size))
				{
					$done = true;

					// Apply the hunk of differences
					$this->applyHunk($lines, $src, $dst, $src_line, $src_size, $dst_line, $dst_size);
				}

				// If no modifications were found, throw an exception
				if (!$done)
				{
					throw new \RuntimeException('Invalid Diff');
				}
			}
		}

		// Initialize the counter
		$done = 0;

		// Patch each destination file
		foreach ($this->destinations as $file => $content)
		{
			$content = implode("\n", $content);

			if (File::write($file, $content))
			{
				if (isset($this->sources[$file]))
				{
					$this->sources[$file] = $content;
				}

				$done++;
			}
		}

		// Remove each removed file
		foreach ($this->removals as $file)
		{
			if (File::delete($file))
			{
				if (isset($this->sources[$file]))
				{
					unset($this->sources[$file]);
				}

				$done++;
			}
		}

		// Clear the destinations cache
		$this->destinations = array();

		// Clear the removals
		$this->removals = array();

		// Clear the patches
		$this->patches = array();

		return $done;
	}
603764
public function apply()
  {
    if (!empty($this->modificators)) {
      foreach ($this->modificators as $k => $mod) {
        switch ($mod['method']) {
          case static::RESIZE:
            $this->doResize($mod['width'], $mod['height']);
            break;
          case static::CROP:
            $this->doCrop($mod['width'], $mod['height'], $mod['x'], $mod['y']);
            break;
          case static::WATERMARK:
            $this->doWatermark($mod['file'], $mod['x'], $mod['y']);
            break;
          case static::CROP_RESIZED:
            $this->doCropResized($mod['width'], $mod['height'], $mod['x'], $mod['y']);
            break;
        }

        unset($this->modificators[$k]);
      }
    }

    return $this;
  }