public function render() : string 
  {
    $sOutput = preg_replace_callback(
      '/{(.*?)}/',
      function ($aResult){
        $aToSearch = explode('.', $aResult[1]);
        $aSearchIn = $this->getData();

        foreach ($aToSearch as $sKey) {
          list(
            $sFormattedKey, 
            $mParam
          )       = self::getFunctionNameAndParameter($sKey);
          $mValue = $aSearchIn[$sFormattedKey];

          if(is_string($mValue)) {

            return $mValue;
          } else if(is_object($mValue)) {
            if($mParam){

              return $mValue($mParam);
            }

            return $mValue();
          }
          
          $aSearchIn = $mValue;
        }

        return (
          $this->hasShowEmpty() 
          ? 
          $aResult[0] 
          : 
          ''
        );
      },
      $this->getTemplate()
    );
    
    return preg_replace('/^\s+|\n|\r|\t/m', '', $sOutput);
  }
public function render() : string 
  {
    $sOutput = preg_replace_callback(
      '/{(.*?)}/',
      function ($aResult){
        $aToSearch = explode('.', $aResult[1]);
        $aSearchIn = $this->getData();

        foreach ($aToSearch as $sKey) {
          list(
            $sFormattedKey, 
            $mParam
          )       = self::getFunctionNameAndParameter($sKey);
          $mValue = $aSearchIn[$sFormattedKey];

          if(is_string($mValue)) {

            return $mValue;
          } else if(is_object($mValue)) {
            if($mParam){

              return $mValue($mParam);
            }

            return $mValue();
          }
          
          $aSearchIn = $mValue;
        }

        return (
          $this->hasShowEmpty() 
          ? 
          $aResult[0] 
          : 
          ''
        );
      },
      $this->getTemplate()
    );
    
    return preg_replace('/^\s+|\n|\r|\t/m', '', $sOutput);
  }
public function render ( ) : string { $ sOutput = preg_replace_callback ( '/{(.*?)}/' , function ( $ aResult ) { $ aToSearch = explode ( '.' , $ aResult [ 1 ] ) ; $ aSearchIn = $ this -> getData ( ) ; foreach ( $ aToSearch as $ sKey ) { list ( $ sFormattedKey , $ mParam ) = self :: getFunctionNameAndParameter ( $ sKey ) ; $ mValue = $ aSearchIn [ $ sFormattedKey ] ; if ( is_string ( $ mValue ) ) { return $ mValue ; } else if ( is_object ( $ mValue ) ) { if ( $ mParam ) { return $ mValue ( $ mParam ) ; } return $ mValue ( ) ; } $ aSearchIn = $ mValue ; } return ( $ this -> hasShowEmpty ( ) ? $ aResult [ 0 ] : '' ) ; } , $ this -> getTemplate ( ) ) ; return preg_replace ( '/^\s+|\n|\r|\t/m' , '' , $ sOutput ) ; }
This method replaces the placeholders in the template string with
the values from the data object and returns the new string.

@return string   the string with the replaced placeholders
This method replaces the placeholders in the template string with the values from the data object and returns the new string .