Skip to content

Commit

Permalink
Renamed getAllByBasename() to getAllByKeyBasename()
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniyal Hamid committed Oct 17, 2021
1 parent 9837edf commit 845b3f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $metadata = $mainfest->getAll();
$css = $mainfest->getAllByType('css');
$images = $mainfest->getAllByTypes(['jpg', 'png']);
$js = $mainfest->getAllByKey('*.js');
$criticalJs = $mainfest->getAllByBasename('critical-*.js');
$criticalJs = $mainfest->getAllByKeyBasename('critical-*.js');
```

## API
Expand Down Expand Up @@ -56,7 +56,7 @@ Gets all files with the specified file extensions (e.g. `['css', 'js']`, etc.) a

Gets all files that match the specified key. It looks for a full match in the manifest entries' key. It can optionally have wildcard using asterisk (e.g. `*.js`, `*index*`, etc.).

### `getAllByBasename(string $key): array`
### `getAllByKeyBasename(string $key): array`

Gets all files that match the trailing name component of path in the manifest entry's key. It can optionally have wildcard using asterisk (e.g. `*.js`, `index*`, etc.).

Expand Down
2 changes: 1 addition & 1 deletion src/ManifestJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getAllByKey(string $key): array
), ARRAY_FILTER_USE_KEY);
}

public function getAllByBasename(string $key): array
public function getAllByKeyBasename(string $key): array
{
$pattern = preg_quote($key, '/');
$pattern = '/^' . str_replace('\*', '.*', $pattern) . '$/i';
Expand Down
4 changes: 2 additions & 2 deletions test/ManifestJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ public function keyBasenameProvider(): array
* @param string $key
* @param array $expected
*/
public function testGetAllByBasename(string $key, array $expected): void
public function testGetAllByKeyBasename(string $key, array $expected): void
{
$this->assertSame($expected, $this->manifest->getAllByBasename($key));
$this->assertSame($expected, $this->manifest->getAllByKeyBasename($key));
}
}

0 comments on commit 845b3f9

Please sign in to comment.