The method should get rid of addition conditions in templates

@param string $code
@param bool $asTitle By default we should display always Title field,
but it should be also possible to use value
@return string|null
510390
public function getFirstValueByAttributeCodeAsString(string $code, $asTitle = true)
    {
        $attributeValue = $this->getFirstValueByAttributeCode($code);

        if (!$attributeValue) {
            return "";
        }

        $field = $asTitle ? 'title' : 'value';

        return $attributeValue->$field;
    }
533614
function (type, code) {
      $sgCodeTitles.removeClass('sg-code-title-active');

      switch (type) {
        case 'e':
          $sgCodeTitleHtml.addClass('sg-code-title-active');

          break;

        case 'm':
          $sgCodeTitleMustache.addClass('sg-code-title-active');

          break;
      }

      $sgCodeFill.removeClass().addClass('language-markup');
      $sgCodeFill.html(code);
      window.Prism.highlightElement($sgCodeFill[0]);

      if (codeViewer.copyOnInit) {
        codeViewer.selectCode();
        codeViewer.copyOnInit = false;
      }
    }
97085
public static function GetNameForCode($code, $args = null, $_ = null)
  {
    if (!array_key_exists($code, static::$errors_arr)) {
      return false;
    }

    $str = static::$errors_arr[$code];

    if (!is_null($args)) {
      if (!is_array($args)) {
        $args = array_slice(func_get_args(), 1);
      }

      array_unshift($args, $str);

      return call_user_func_array('sprintf', $args);
    }

    return $str;
  }
603951
protected static function createSymbol(\SimpleXMLElement $sNode, $code)
    {
        switch((string) $sNode['type']) {
            case 'UCS':
                $symbol = (string) $sNode['UTF-8'];
                break;
            case null: //no symbol - use code
            default:
                $symbol = $code;
                break;
        }

        return $symbol;
    }
1355963
public function setConfirmCode($code)
    {
        if (!$this->confirmCodeAttribute || empty($this->confirmCodeAttribute)) {
            return;
        }
        $confirmCodeAttribute = $this->confirmCodeAttribute;
        $this->$confirmCodeAttribute = $code;
        if (!$this->confirmTimeAttribute) {
            return;
        }
        $confirmTimeAttribute = $this->confirmTimeAttribute;
        if (!empty($code)) {
            $this->$confirmTimeAttribute = date('Y-m-d H:i:s');
            return;
        }
        $this->$confirmTimeAttribute = $this->initConfirmTime;
    }
476600
public function setTitleExact($value)
    {
        if ($value != null) {
            $this->_params['title-exact'] = $value;
        } else {
            unset($this->_params['title-exact']);
        }
        return $this;
    }
434764
public function gameTitleId() : ?string
    {
        if ($this->titleType() & SessionType::Unknown) return null; 

        return $this->session->npTitleDetail->npTitleId;
    }
910600
public static function title($value, $encoding = null)
    {
        $options  = [];
        $encoding = $encoding ?: static::$encoding;

        if ($encoding) {
            $options['encoding'] = $encoding;
        }

        return StaticFilter::execute(
            static::camelCaseToUnderscore($value), Filter\UpperCaseWords::class, $options
        );
    }
1002734
public function replace($code, array $placeholders = [])
    {
        $code = Helper::toType($code);
        if (empty($code) || !is_string($code)) {
            return $code;
        }
        if (!empty($placeholders)) {
            $this->addMultiPlaceholders($placeholders);
        }
        /*
         * Remove tpl-comment
         * ```
         * {* Comment about *}
         * ```
         */
        $code = preg_replace('/\{\*.*?\*\}/is', "", $code);
        $code = preg_replace_callback(
            '/
                (?P<beforeSkip>\{\!\\s*)?\[\[
                (?P<sanitizeDisable>\!)?
                (?P<type>[\#\%\~\$]?|\+{1,2}|@{1,2})					# search type of variable template
                (?P<name>@?[\\w\-\/\\\.\$]+)							# name of variable template [\w, -, \, .]
                (?:[^\[\]]++ | \[(?!\[) | \](?!\]) | (?R))*		# possible recursion
                \]\](?P<afterSkip>\\s*\!\})?
            /iux',
            [$this, 'replaceCallback'],
            $code
        );
        return Helper::toType($code);
    }
877793
protected function formatTitleWithAccessKey( $title ) {
		if ( $this->fieldWidget && method_exists( $this->fieldWidget, 'formatTitleWithAccessKey' ) ) {
			return $this->fieldWidget->formatTitleWithAccessKey( $title );
		}
		return $title;
	}
1344889
public void setCode(final String code) {
        if (isAttached()) {
            setCode(getElement(), code);
        } else {
            getElement().setInnerHTML(code);
        }
    }
349361
protected function compare($code, $expectedCode)
    {
        return ($expectedCode !== null && is_string($expectedCode) && $this->niceize($code) == $this->niceize($expectedCode));
    }
115687
public function getByCode($code)
    {
        if (\is_scalar($code) && ! empty($code = trim($this->uppercaseAndSafeTransliterate($code)))) {
            foreach ($this->items as $auto_category) {
                if ($auto_category->getCode() === $code) {
                    return $auto_category;
                }
            }
        }
    }
786224
public function whereTitle($title, callable $callback = null)
    {
        $item = $this->findBy('title', $title);

        if (is_callable($callback)) {
            return call_user_func($callback, $item);
        }

        return $item;
    }
1009513
private function isValidXmlTag( $code )
    {
        if ( $code[strlen( $code ) - 1] !== '/' )
        {
            $code .= '/';
        }
        $code .= '>';
        $code = '<' . str_replace(
            array( '<', '&' ),
            array( '&lt;', '&amp;' ),
            substr( $code, 1 )
        );
        $errorHanding = libxml_use_internal_errors( true );
        $simpleXml = simplexml_load_string( $code );
        libxml_use_internal_errors( $errorHanding );
        return ( $simpleXml !== false );
    }
1212980
protected function createMethod($code, $title, $price)
    {
        /** @var Mage_Shipping_Model_Rate_Result_Method $method */
        $method = Mage::getModel('shipping/rate_result_method');

        $method->setCarrier($this->_code);
        $method->setCarrierTitle($this->getConfigData('title'));

        $method->setMethod($code);
        $method->setMethodTitle($title);

        $method->setPrice($this->getFinalPriceWithHandlingFee($price));

        return $method;
    }
129011
function title( $contentObjectAttribute, $name = null )
    {
        $enum = $this->objectAttributeContent( $contentObjectAttribute );

        $enumObjectList = $enum->attribute( 'enumobject_list' );

        $value = '';

        foreach ( $enumObjectList as $count => $enumObjectValue )
        {
            if ( $count != 0 )
                $value .= ', ';
            $value .= $enumObjectValue->attribute( 'enumelement' );
        }

        return $value;
    }