dump() public static method

Dump some scalar data using a string representation
public static dump ( mixed $value, $quote = '"' ) : string
$value mixed The scalar data to dump
return string The dumped string.
Beispiel #1
0
        });
        it("dumps a string with double quote", function () {
            $dump = Text::dump('Hel"lo');
            $this->expect($dump)->toBe('"Hel\\"lo"');
        });
        it("dumps a string with simple quote", function () {
            $dump = Text::dump("Hel'lo", "'");
            $this->expect($dump)->toBe("'Hel\\'lo'");
        });
        it("expands escape sequences and escape special chars", function () {
            $dump = Text::dump(" \t \nHello   \r\n \v \f World\n\n");
            $this->expect($dump)->toBe("\" \\t \\nHello \\x07 \\x08 \\r\\n \\v \\f World\\n\\n\"");
        });
        it("expands an empty string as \"\"", function () {
            $dump = Text::dump('');
            $this->expect($dump)->toBe('""');
        });
        it("expands an zero string as 0", function () {
            $dump = Text::dump('2014');
            $this->expect($dump)->toBe('"2014"');
        });
        it("expands espcape special chars", function () {
            $dump = Text::dump('20$14');
            $this->expect($dump)->toBe('"20\\$14"');
            $dump = Text::dump('20"14');
            $this->expect($dump)->toBe('"20\\"14"');
            $dump = Text::dump('20\\14');
            $this->expect($dump)->toBe('"20\\\\14"');
        });
    });
});
Beispiel #2
0
 protected function _reportException($exception)
 {
     $msg = '`' . get_class($exception) . '` Code(' . $exception->getCode() . ') with ';
     $message = $exception->getMessage();
     if ($message) {
         $msg .= 'message ' . Text::dump($exception->getMessage());
     } else {
         $msg .= 'no message';
     }
     $this->write("{$msg}\n\n");
 }
Beispiel #3
0
 public function dump($value)
 {
     return Text::dump($value);
 }
Beispiel #4
0
 protected function dump()
 {
     return Text::dump('Hello');
 }