File tree Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 1
1
# INI
2
2
3
- [ ![ License] ( https://img.shields.io/packagist/l /phppkg/ini.svg ?style=flat-square )] ( LICENSE )
4
- [ ![ Php Version] ( https://img.shields.io/badge /php-%3E=7.2.0-brightgreen.svg ?maxAge=2592000 )] ( https://packagist.org/packages/phppkg/ini )
3
+ [ ![ License] ( https://img.shields.io/github/license /phppkg/ini?style=flat-square )] ( LICENSE )
4
+ [ ![ Php Version] ( https://img.shields.io/packagist /php-v/phppkg/ini ?maxAge=2592000 )] ( https://packagist.org/packages/phppkg/ini )
5
5
[ ![ GitHub tag (latest SemVer)] ( https://img.shields.io/github/tag/phppkg/ini )] ( https://github.com/phppkg/ini )
6
6
[ ![ Actions Status] ( https://github.com/phppkg/ini/workflows/Unit-Tests/badge.svg )] ( https://github.com/phppkg/ini/actions )
7
7
14
14
- enhance: supports inline array value
15
15
- enhance: supports multi inline string. use ` ''' ` or ` """ `
16
16
- enhance: supports add interceptor before collect value
17
+ - TODO: support parse ENV var. ` ${SHELL | bash} `
17
18
18
19
## Install
19
20
Original file line number Diff line number Diff line change 11
11
*/
12
12
class IniEncoder
13
13
{
14
+ /**
15
+ * @return static
16
+ */
17
+ public static function new (): self
18
+ {
19
+ return new self ();
20
+ }
21
+
14
22
/**
15
23
* @param array|Traversable $data
16
24
* @param int $flags
Original file line number Diff line number Diff line change 13
13
use function str_starts_with ;
14
14
use function strlen ;
15
15
use function strpos ;
16
- use function strstr ;
17
16
use function substr ;
18
17
use function trim ;
19
18
@@ -79,7 +78,7 @@ class IniParser
79
78
*
80
79
* @return static
81
80
*/
82
- public static function new (string $ source ): self
81
+ public static function new (string $ source = '' ): self
83
82
{
84
83
return new self ($ source );
85
84
}
@@ -89,7 +88,7 @@ public static function new(string $source): self
89
88
*
90
89
* @param string $source
91
90
*/
92
- public function __construct (string $ source )
91
+ public function __construct (string $ source = '' )
93
92
{
94
93
$ this ->source = $ source ;
95
94
}
@@ -282,6 +281,28 @@ public function getSource(): string
282
281
return $ this ->source ;
283
282
}
284
283
284
+ /**
285
+ * @param string $source
286
+ *
287
+ * @return IniParser
288
+ */
289
+ public function setSource (string $ source ): self
290
+ {
291
+ $ this ->source = $ source ;
292
+ return $ this ;
293
+ }
294
+
295
+ /**
296
+ * @param callable $interceptor
297
+ *
298
+ * @return IniParser
299
+ */
300
+ public function addInterceptor (callable $ interceptor ): self
301
+ {
302
+ $ this ->interceptors [] = $ interceptor ;
303
+ return $ this ;
304
+ }
305
+
285
306
/**
286
307
* @param callable[] $interceptors
287
308
*
You can’t perform that action at this time.
0 commit comments