Dumps outline example.

@param string  $keyword Item keyword
@param Boolean $short   Dump short version?

@return string
329055
protected function dumpOutline($keyword, $short = true, $excludeAsterisk = false)
    {
        $dump = <<<GHERKIN
  {$keyword}: Erasing other agents' memory

GHERKIN;

        // Given
        $dump .= $this->dumpStep(
            $this->keywords->getGivenKeywords(),
            'there is agent <agent1>',
            $short,
            $excludeAsterisk
        );

        // And
        $dump .= $this->dumpStep(
            $this->keywords->getAndKeywords(),
            'there is agent <agent2>',
            $short,
            $excludeAsterisk
        );

        // When
        $dump .= $this->dumpStep(
            $this->keywords->getWhenKeywords(),
            'I erase agent <agent2>\'s memory',
            $short,
            $excludeAsterisk
        );

        // Then
        $dump .= $this->dumpStep(
            $this->keywords->getThenKeywords(),
            'there should be agent <agent1>',
            $short,
            $excludeAsterisk
        );

        // But
        $dump .= $this->dumpStep(
            $this->keywords->getButKeywords(),
            'there should not be agent <agent2>',
            $short,
            $excludeAsterisk
        );

        $keywords = explode('|', $this->keywords->getExamplesKeywords());
        if ($short) {
            $keyword = call_user_func($this->keywordsDumper, $keywords, $short);
        } else {
            $keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short);
        }

        $dump .= <<<GHERKIN

    {$keyword}:
      | agent1 | agent2 |
      | D      | M      |

GHERKIN;

        return $dump . "\n";
    }
683958
protected function _collectMetaKeyword($keywords)
    {
        $maxTextLength = 60;
        $text = '';

        if (count($articleList = $this->getArticleList())) {
            $stringModifier = getStr();
            foreach ($articleList as $article) {
                /** @var \OxidEsales\Eshop\Application\Model\Article $article */
                $description = $stringModifier->strip_tags(trim($stringModifier->strtolower($article->getLongDescription()->value)));

                //removing dots from string (they are not cleaned up during general string cleanup)
                $description = $stringModifier->preg_replace("/\./", " ", $description);

                if ($stringModifier->strlen($description) > $maxTextLength) {
                    $midText = $stringModifier->substr($description, 0, $maxTextLength);
                    $description = $stringModifier->substr(
                        $midText,
                        0,
                        ($stringModifier->strlen($midText) - $stringModifier->strpos(strrev($midText), ' '))
                    );
                }
                if ($text) {
                    $text .= ', ';
                }
                $text .= $description;
            }
        }

        if (!$keywords) {
            $keywords = $this->_getCatPathString();
        }

        if ($keywords) {
            $text = "{$keywords}, {$text}";
        }

        return parent::_prepareMetaKeyword($text);
    }
775072
public function searchList($keyword = "")
    {
        $controller = $this->config['controller'];
        $list = [];
        foreach ($controller as $class)
        {
            if(class_exists($class))
            {
                $reflection = new \ReflectionClass($class);
                $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
                $filter_method = array_merge(['__construct'], $this->config['filter_method']);
                foreach ($method as $action){
                    if(!in_array($action->name, $filter_method))
                    {
                        $doc = new DocParser();
                        $doc_str = $action->getDocComment();
                        if($doc_str)
                        {
                            $action_doc = $doc->parse($doc_str);
                            $action_doc['name'] = $class."::".$action->name;
                            if((isset($action_doc['title']) && strpos($action_doc['title'], $keyword) !== false)
                                    || (isset($action_doc['description']) && strpos($action_doc['description'], $keyword) !== false)
                                    || (isset($action_doc['author']) && strpos($action_doc['author'], $keyword) !== false)
                                    || (isset($action_doc['url'])  && strpos($action_doc['url'], $keyword) !== false))
                            {
                                array_push($list, $action_doc);
                            }
                        }
                    }
                }
            }
        }
        return $list;
    }
1004924
private function prepareKeywords($keywords)
    {
        if ($keywords === null)
            return null;

        if (is_array($keywords))
            $keywords = implode(', ', $keywords);

        return strtolower(strip_tags($keywords));
    }
1012707
protected function getDescription($shortName)
    {
        return sprintf(
            '%s has been %s with %s = "%s"',
            $shortName,
            $this->getEventShortName(),
            $this->getIdField(),
            $this->getIdValue()
        );
    }
540962
public static function __($short, $chunks){
		$translated = self::_($short);
		foreach($chunks as $k=>$v){
			$translated = str_replace('%'.$k.'%', $v, $translated);
			}
		return $translated;
		}
742118
public function getLabel($short = false)
    {
        if (!$this->label) {
            $this->label = $this->generateLabel();
            if ($this->hasShortLabel()) {
                $this->label_short = $this->generateLabelShort();
            }
        }

        return $short ? $this->label_short : $this->label;
    }
341634
public function getContentType($short = true)
    {
        if (isset($_SERVER['CONTENT_TYPE'])) {
            $content_type = $_SERVER['CONTENT_TYPE'];
            if ($short) {
                return Utils::substrToString($content_type,';');
            }
            return $content_type;
        }
        return null;
    }
474489
public function Link($short = false)
    {
        if ($this->getIsDefaultEntity()) {
            $base = Controller::join_links(
                Director::baseURL(),
                Config::inst()->get('DocumentationViewer', 'link_base'),
                $this->getLanguage(),
                '/'
            );
        } else {
            $base = Controller::join_links(
                Director::baseURL(),
                Config::inst()->get('DocumentationViewer', 'link_base'),
                $this->getLanguage(),
                $this->getKey(),
                '/'
            );
        }

        if ($short && $this->stable) {
            return $base;
        }

        return Controller::join_links(
            $base,
            $this->getVersion(),
            '/'
        );
    }
588921
public function shortName($name = null)
    {
        if ($name === null) {
            return $this->_nameShort;
        }
        $this->_nameShort = $name;

        return $this;
    }
564662
public function get_details($short = '') {
        global $DB, $OUTPUT;
        $output = array();
        foreach ($this->params as $p) {
            $coursename = $DB->get_field('course', 'fullname', array('id' => $p['course']));
            if (!$coursename) {
                $str = $OUTPUT->error_text(get_string('error:nosuchcourse', 'badges'));
            } else {
                $str = html_writer::tag('b', '"' . $coursename . '"');
                if (isset($p['bydate'])) {
                    $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig')));
                }
                if (isset($p['grade'])) {
                    $str .= get_string('criteria_descr_grade', 'badges', $p['grade']);
                }
            }
            $output[] = $str;
        }

        if ($short) {
            return implode(', ', $output);
        } else {
            return html_writer::alist($output, array(), 'ul');
        }
    }
153433
public function getMbShortcode($shortcodeName)
    {
        if (!$this->mbShortCodes->has($shortcodeName)) {
            throw new MbException("The shortcode {$shortcodeName} has not been added to the MocaBonita shortcode list!");
        }

        return $this->mbShortCodes->get($shortcodeName);
    }
438417
public function dumpAsHtml()
	{
		$arguments = func_get_args();
		$total = count($arguments);

		$backtrace = debug_backtrace();

		// locate the first file entry that isn't this class itself
		foreach ($backtrace as $stack => $trace)
		{
			if (isset($trace['file']))
			{
				// If being called from within, or using call_user_func(), get the next entry
				if (strpos($trace['function'], 'call_user_func') === 0 or (isset($trace['class']) and $trace['class'] == get_class($this)))
				{
					continue;
				}

				$callee = $trace;
				$label = $this->inflector->humanize($backtrace[$stack+1]['function']);

				// get info about what was dumped
				$callee['code'] = '';
				for ($i = $callee['line']; $i > 0; $i--)
				{
					$line = $this->fileLines($callee['file'], $i, false, 0);
					$callee['code'] = reset($line).' '.trim($callee['code']);
					$tokens = token_get_all('<?php '.trim($callee['code']));
					if (is_array($tokens[1]) and isset($tokens[1][0]) and $tokens[1][0] != 377)
					{
						break;
					}
				}

				$results = array();
				$r = false;
				$c = 0;

				foreach($tokens as $token)
				{
					// skip everything before our function call
					if ($r === false)
					{
						if (isset($token[1]) and $token[1] == $callee['function'])
						{
							$r = 0;
						}
						continue;
					}

					// and quit if we find an end-of-statement
					if ($token == ';')
					{
						break;
					}

					// check for a start-of-expresssion
					elseif ($token == '(')
					{
						$c++;
						if ($c === 1)
						{
							continue;
						}
					}

					// check for an end-of-expresssion
					elseif ($token == ')')
					{
						$c--;
						if ($c === 0)
						{
							$r++;
							continue;
						}
					}

					// new expression in the same dump
					elseif ($token == ',' and $c === 1)
					{
						$r++;
						continue;
					}

					// make sure we have an array entry to add to, and add the token
					if ( ! isset($results[$r]))
					{
						$results[$r] = '';
					}
					$results[$r] .= is_array($token) ? $token[1] : $token;
				}

				// make sure we've parsed the same number of expressions as we have arguments
				if (count($results) == $total)
				{
					$callee['code'] = $results;
				}
				else
				{
					// parsing failed, try it the old fashioned way
					if (preg_match('/(.*'.$callee['function'].'\()(.*?)\);(.*)/', $callee['code'], $matches))
					{
						$callee['code'] = 'Variable'.($total==1?'':'s').' dumped: '.$matches[2];
					}
				}

				$callee['file'] = cleanpath($callee['file']);

				break;
			}
		}

		if ( ! $this->jsDisplayed)
		{
			echo <<<JS
<script type="text/javascript">function fuel_debug_toggle(a){if(document.getElementById){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block"}else{document.getElementById(a).style.display="none"}}else{if(document.layers){if(document.id.display=="none"){document.id.display="block"}else{document.id.display="none"}}else{if(document.all.id.style.display=="none"){document.all.id.style.display="block"}else{document.all.id.style.display="none"}}}};</script>
JS;
			$this->jsDisplayed = true;
		}

		echo '<div class="fuelphp-dump" style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;">';
		echo '<h1 style="padding: 0 0 5px 0; margin: 0; font: bold 110% sans-serif;">File: '.$callee['file'].' @ line: '.$callee['line'].'</h1>';
		if (is_string($callee['code']))
		{
			echo '<h5 style="border-bottom: 1px solid #CCC;padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 85% sans-serif;">'.$callee['code'].'</h5>'.PHP_EOL;
		}
		echo '<pre style="overflow:auto;font-size:100%;">';

		$i = 0;
		foreach ($arguments as $argument)
		{
			if (is_string($callee['code']))
			{
				echo '<strong>Variable #'.(++$i).' of '.$total.':</strong>'.PHP_EOL;
			}
			elseif (substr(trim($callee['code'][$i]),0,1) == '$')
			{
				echo '<strong>Variable: '.trim($callee['code'][$i++]).'</strong>'.PHP_EOL;
			}
			else
			{
				echo '<strong>Expression: '.trim($callee['code'][$i++]).'</strong>'.PHP_EOL;
			}
			echo $this->format('', $argument);
			if ($i < $total)
			{
				echo PHP_EOL;
			}
		}

		echo "</pre>";
		echo "</div>";
	}
985549
public function createKeywordIfNotExists($keyword, $do_persist = true)
    {
        if (null === $keyword_object = $this->em->getRepository('BackBee\NestedNode\KeyWord')->exists($keyword)) {
            $keyword_object = new \BackBee\NestedNode\KeyWord();
            $keyword_object->setRoot($this->em->find('BackBee\NestedNode\KeyWord', md5('root')));
            $keyword_object->setKeyWord(preg_replace('#[/\"]#', '', trim($keyword)));

            if (true === $do_persist) {
                $this->em->persist($keyword_object);
                $this->em->flush($keyword_object);
            }
        }

        return $keyword_object;
    }
854537
public function dump($result = null)
	{
		static $keywords1 = 'SELECT|(?:ON\s+DUPLICATE\s+KEY)?UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|FETCH\s+NEXT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE|START\s+TRANSACTION|BEGIN|COMMIT|ROLLBACK(?:\s+TO\s+SAVEPOINT)?|(?:RELEASE\s+)?SAVEPOINT';
		static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|IGNORE|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|RLIKE|REGEXP|TRUE|FALSE';

		// insert new lines
		$sql = " $result ";
		$sql = \preg_replace("#(?<=[\\s,(])($keywords1)(?=[\\s,)])#i", "\n\$1", $sql);
		// reduce spaces
		$sql = \preg_replace('#[ \t]{2,}#', ' ', $sql);
		$sql = \wordwrap($sql, 100);
		$sql = \preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);
		// syntax highlight
		$highlighter = "#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is";

		$sql = \htmlspecialchars($sql);
		$sql = \preg_replace_callback($highlighter, function ($m) {
			if (!empty($m[1])) { // comment
				return '<em style="color:gray">' . $m[1] . '</em>';
			}

			if (!empty($m[2])) { // error
				return '<strong style="color:red">' . $m[2] . '</strong>';
			}

			if (!empty($m[3])) { // most important keywords
				return '<strong style="color:blue">' . $m[3] . '</strong>';
			}

			if (!empty($m[4])) { // other keywords
				return '<strong style="color:green">' . $m[4] . '</strong>';
			}

			return '';
		}, $sql);

		return '<pre class="dump">' . \trim($sql) . "</pre>\n\n";
	}
1180534
public function get_details($short = '') {
        global $DB, $OUTPUT;
        $output = array();
        foreach ($this->params as $p) {
            if (is_numeric($p['field'])) {
                $str = $DB->get_field('user_info_field', 'name', array('id' => $p['field']));
            } else {
                $str = get_user_field_name($p['field']);
            }
            if (!$str) {
                $output[] = $OUTPUT->error_text(get_string('error:nosuchfield', 'badges'));
            } else {
                $output[] = $str;
            }
        }

        if ($short) {
            return implode(', ', $output);
        } else {
            return html_writer::alist($output, array(), 'ul');
        }
    }
1193782
public function writeShort($short)
    {
        try {
            $this->getStream()->write(pack('S', $short));
        } catch (StreamException $e) {
            $this->handleStreamException($e, BinaryStreamAccessException::SHORT, false);
        }
    }