Skip to content

Commit 52ce7bc

Browse files
authored
Update README.md
1 parent 29bb489 commit 52ce7bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ $snippet = (new CodeSnippet())
111111
echo "Snippet line count: " . count($snippet->getLines()) . PHP_EOL;
112112
```
113113

114+
### Returning the snippet as a string
115+
116+
Return the contents of the snippet as as string using the `toString()` method or by casting the snippet to a string directly:
117+
118+
```php
119+
$snippet = (new CodeSnippet())
120+
->surroundingLines(4, 7)
121+
->linesBefore(3)
122+
->linesAfter(3)
123+
->fromFile('/path/to/a/file.php');
124+
125+
echo "Snippet: \n" . $snippet->toString() . PHP_EOL;
126+
```
114127

115128
## Testing
116129

0 commit comments

Comments
 (0)