Skip to content

Commit a8dfd71

Browse files
committed
up: update readme and add some new methods
1 parent 82e264e commit a8dfd71

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# INI
22

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)
55
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/phppkg/ini)](https://github.com/phppkg/ini)
66
[![Actions Status](https://github.com/phppkg/ini/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/ini/actions)
77

@@ -14,6 +14,7 @@
1414
- enhance: supports inline array value
1515
- enhance: supports multi inline string. use `'''` or `"""`
1616
- enhance: supports add interceptor before collect value
17+
- TODO: support parse ENV var. `${SHELL | bash}`
1718

1819
## Install
1920

src/IniEncoder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
*/
1212
class IniEncoder
1313
{
14+
/**
15+
* @return static
16+
*/
17+
public static function new(): self
18+
{
19+
return new self();
20+
}
21+
1422
/**
1523
* @param array|Traversable $data
1624
* @param int $flags

src/IniParser.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use function str_starts_with;
1414
use function strlen;
1515
use function strpos;
16-
use function strstr;
1716
use function substr;
1817
use function trim;
1918

@@ -79,7 +78,7 @@ class IniParser
7978
*
8079
* @return static
8180
*/
82-
public static function new(string $source): self
81+
public static function new(string $source = ''): self
8382
{
8483
return new self($source);
8584
}
@@ -89,7 +88,7 @@ public static function new(string $source): self
8988
*
9089
* @param string $source
9190
*/
92-
public function __construct(string $source)
91+
public function __construct(string $source = '')
9392
{
9493
$this->source = $source;
9594
}
@@ -282,6 +281,28 @@ public function getSource(): string
282281
return $this->source;
283282
}
284283

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+
285306
/**
286307
* @param callable[] $interceptors
287308
*

0 commit comments

Comments
 (0)