Download the PHP package corncodecreators/line-dumper without Composer
On this page you can find all versions of the php package corncodecreators/line-dumper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download corncodecreators/line-dumper
More information about corncodecreators/line-dumper
Files in corncodecreators/line-dumper
Download corncodecreators/line-dumper
More information about corncodecreators/line-dumper
Files in corncodecreators/line-dumper
Vendor corncodecreators
Package line-dumper
Short Description Show and compare strings - line by line.
License MIT
Package line-dumper
Short Description Show and compare strings - line by line.
License MIT
Please rate this library. Is it a good library?
Informations about the package line-dumper
LineDumper
Show and compare strings - line by line.
Summary
This PHP class, LineDumper, provides a utility for comparing two strings line by line and highlights the differences between them.
-
If the strings are identical, it simply returns "Strings are equal!".
- If they differ, it compares them line by line, indicating mismatches with color-coded output using ANSI escape codes.
Details
- Namespace and Class Definition: The class is defined under the CornCodeCreators namespace.
- compareLines Method:
- Input: It takes two strings, $expectedString and $actualString, which represent the expected output and the actual output.
- Output: It returns a string containing either a confirmation that the strings are equal or a line-by-line comparison highlighting differences.
- String Splitting: The strings are split into arrays of lines using explode("\n", $string).
- Line Number Width: The line numbers are padded to a width of 3 characters.
- Comparison: Each line from the expected string is compared to the corresponding line in the actual string:
- If the lines match, it outputs them with a simple "ok" status.
- If they don't match, it outputs the expected line in yellow (to-be) and the actual line in red (as-is).
Example
Input
Output
Installation
All versions of line-dumper with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
The package corncodecreators/line-dumper contains the following files
Loading the files please wait ...