src/Beluga/Type.php
public final function getPhpCode() : string
   {

      $str = $this->stringValue;

      switch ( $this->typeName )
      {

         case Type::PHP_BOOLEAN:
         case 'boolean':
            return ( $this->value ? 'true' : 'false' );

         case Type::PHP_DOUBLE:
         case Type::PHP_FLOAT:
         case Type::PHP_INTEGER:
         case 'integer':
            return $str;

         case Type::PHP_STRING:
            if ( \preg_match( "~[\r\n\t]+~", $str ) )
            {
               $str = \str_replace(
                  array( '\\',  "\r", "\n", "\t", "\0", '"',  '$' ),
                  array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ),
                  $str
               );
               return '"' . $str . '"';
            }
            return "'" . \str_replace(
                  array( '\\',   "'" ),
                  array( '\\\\', "\\'" ),
                  $str
               )
               . "'";

         case Type::PHP_RESOURCE:
         case Type::PHP_NULL:
         case Type::PHP_UNKNOWN:
            return 'null';

         default:
            $str = \serialize( $this->value );
            if ( \preg_match( "~[\r\n\t]+~", $str ) )
            {
               $str = \str_replace(
                  array( '\\',  "\r", "\n", "\t", "\0", '"',  '$' ),
                  array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ),
                  $str
               );
            }
            else
            {
               $str = \str_replace(
                  array('\\',   '"',   '$'),
                  array('\\\\', '\\"', '\\$'),
                  $str );
            }
            return '\unserialize("' . $str . '")';

      }

   }
public final function getPhpCode() : string
   {

      $str = $this->stringValue;

      switch ( $this->typeName )
      {

         case Type::PHP_BOOLEAN:
         case 'boolean':
            return ( $this->value ? 'true' : 'false' );

         case Type::PHP_DOUBLE:
         case Type::PHP_FLOAT:
         case Type::PHP_INTEGER:
         case 'integer':
            return $str;

         case Type::PHP_STRING:
            if ( \preg_match( "~[\r\n\t]+~", $str ) )
            {
               $str = \str_replace(
                  array( '\\',  "\r", "\n", "\t", "\0", '"',  '$' ),
                  array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ),
                  $str
               );
               return '"' . $str . '"';
            }
            return "'" . \str_replace(
                  array( '\\',   "'" ),
                  array( '\\\\', "\\'" ),
                  $str
               )
               . "'";

         case Type::PHP_RESOURCE:
         case Type::PHP_NULL:
         case Type::PHP_UNKNOWN:
            return 'null';

         default:
            $str = \serialize( $this->value );
            if ( \preg_match( "~[\r\n\t]+~", $str ) )
            {
               $str = \str_replace(
                  array( '\\',  "\r", "\n", "\t", "\0", '"',  '$' ),
                  array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ),
                  $str
               );
            }
            else
            {
               $str = \str_replace(
                  array('\\',   '"',   '$'),
                  array('\\\\', '\\"', '\\$'),
                  $str );
            }
            return '\unserialize("' . $str . '")';

      }

   }
public final function getPhpCode ( ) : string { $ str = $ this -> stringValue ; switch ( $ this -> typeName ) { case Type :: PHP_BOOLEAN : case 'boolean' : return ( $ this -> value ? 'true' : 'false' ) ; case Type :: PHP_DOUBLE : case Type :: PHP_FLOAT : case Type :: PHP_INTEGER : case 'integer' : return $ str ; case Type :: PHP_STRING : if ( \ preg_match ( "~[\r\n\t]+~" , $ str ) ) { $ str = \ str_replace ( array ( '\\' , "\r" , "\n" , "\t" , "\0" , '"' , '$' ) , array ( '\\\\' , '\\r' , '\\n' , '\\t' , '\\0' , '\\"' , '\\$' ) , $ str ) ; return '"' . $ str . '"' ; } return "'" . \ str_replace ( array ( '\\' , "'" ) , array ( '\\\\' , "\\'" ) , $ str ) . "'" ; case Type :: PHP_RESOURCE : case Type :: PHP_NULL : case Type :: PHP_UNKNOWN : return 'null' ; default : $ str = \ serialize ( $ this -> value ) ; if ( \ preg_match ( "~[\r\n\t]+~" , $ str ) ) { $ str = \ str_replace ( array ( '\\' , "\r" , "\n" , "\t" , "\0" , '"' , '$' ) , array ( '\\\\' , '\\r' , '\\n' , '\\t' , '\\0' , '\\"' , '\\$' ) , $ str ) ; } else { $ str = \ str_replace ( array ( '\\' , '"' , '$' ) , array ( '\\\\' , '\\"' , '\\$' ) , $ str ) ; } return '\unserialize("' . $ str . '")' ; } }
Returns the PHP code, defining the current base value.

@return string
Returns the PHP code defining the current base value .