File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 "php" : " ^7.2.5|^8.0" ,
1919 "ext-dom" : " *" ,
2020 "ext-mbstring" : " *" ,
21- "andrey-helldar/support" : " ^2.0|^3.0 "
21+ "andrey-helldar/support" : " ^3.4 "
2222 },
2323 "require-dev" : {
2424 "phpunit/phpunit" : " ^8.0|^9.0"
Original file line number Diff line number Diff line change @@ -42,9 +42,9 @@ public function loadRaw(string $filename)
4242 return file_get_contents ($ filename );
4343 }
4444
45- public function store (string $ path ): void
45+ public function store (string $ path, string $ stub = StubTool:: PHP_ARRAY ): void
4646 {
47- $ content = Stub::replace (StubTool:: PHP_ARRAY , [
47+ $ content = Stub::replace ($ stub , [
4848 '{{slot}} ' => $ this ->content ,
4949 ]);
5050
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests ;
4+
5+ use Helldar \PrettyArray \Services \File ;
6+
7+ class FormatterStoringCustomStubText extends TestCase
8+ {
9+ public function testStoring ()
10+ {
11+ $ service = $ this ->service ();
12+
13+ $ service ->setKeyAsString ();
14+ $ service ->setEqualsAlign ();
15+
16+ $ array = $ this ->requireSource ();
17+ $ formatted = $ service ->raw ($ array );
18+
19+ $ src_file = $ this ->path ('custom-array.txt ' );
20+ $ dst_file = $ this ->path ('stored.php ' );
21+
22+ $ stub = __DIR__ . '/stubs/custom.txt ' ;
23+
24+ File::make ($ formatted )
25+ ->store ($ dst_file , $ stub );
26+
27+ $ this ->assertFileExists ($ dst_file );
28+ $ this ->assertFileEquals ($ src_file , $ dst_file );
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ // Foo
4+ // Bar
5+
6+ /*
7+ * Foo Bar
8+ */
9+
10+ return [
11+ 'foo' => 1,
12+ 'bar' => 2,
13+ 'baz' => 3,
14+ 'qwe rty' => 'qaz',
15+ 'baq' => [
16+ '0' => 'qwe',
17+ '1' => 'rty',
18+ 'asd' => 'zxc',
19+ ],
20+ 'asd fgh' => [
21+ 'foo bar baz' => 'qwe',
22+ '2' => 'rty',
23+ 'qaw sed' => 'zxc',
24+ ],
25+ '2' => 'iop',
26+ ];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ // Foo
4+ // Bar
5+
6+ /*
7+ * Foo Bar
8+ */
9+
10+ return {{slot}};
You can’t perform that action at this time.
0 commit comments