Skip to content

Commit

Permalink
Separate chain calls (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
sankaest committed Jun 1, 2022
1 parent 1efa6f1 commit 40ea784
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -106,7 +106,9 @@ The following methods are available:
## Inflector usage

```php
echo (new \Yiisoft\Strings\Inflector())->withoutIntl()->toSlug('Strings are cool!'); // strings-are-cool
echo (new \Yiisoft\Strings\Inflector())
->withoutIntl()
->toSlug('Strings are cool!'); // strings-are-cool
```

Overall the inflector has the following method groups.
Expand Down Expand Up @@ -171,7 +173,9 @@ The following characters are special in the pattern:
use \Yiisoft\Strings\WildcardPattern;

$startsWithTest = new WildcardPattern('test*');
if ($startsWithTest->ignoreCase()->match('tEStIfThisIsTrue')) {
if ($startsWithTest
->ignoreCase()
->match('tEStIfThisIsTrue')) {
echo 'It starts with "test"!';
}
```
Expand Down
20 changes: 12 additions & 8 deletions tests/InflectorTest.php
Expand Up @@ -212,7 +212,9 @@ public function testToSlugCommons(string $input, string $expected, string $repla
if (\extension_loaded('intl')) {
$this->assertEquals($expected, $inflector->toSlug($input, $replacement));
}
$this->assertEquals($expected, $inflector->withoutIntl()->toSlug($input, $replacement));
$this->assertEquals($expected, $inflector
->withoutIntl()
->toSlug($input, $replacement));
}

public function testToSlugWithIntl(): void
Expand Down Expand Up @@ -403,13 +405,15 @@ public function testToTransliteratedWithTransliterationMap(): void
$this->markTestSkipped('intl extension is required.');
}

$inflector = (new Inflector())->withoutIntl()->withTransliterationMap(
[
'O' => 'E',
'N' => 'N',
'E' => 'O',
]
);
$inflector = (new Inflector())
->withoutIntl()
->withTransliterationMap(
[
'O' => 'E',
'N' => 'N',
'E' => 'O',
]
);
$this->assertEquals('ENO', $inflector->toTransliterated('ONE'));
}

Expand Down

0 comments on commit 40ea784

Please sign in to comment.