Skip to content

Commit a68ffbf

Browse files
committed
adding composer script documentation
1 parent 030f314 commit a68ffbf

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

.gitattributes

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
/.github export-ignore
66
/.gitignore export-ignore
77
/.php_cs export-ignore
8-
/.scrutinizer.yml export-ignore
98
/.travis.yml export-ignore
109
/README.md export-ignore
1110
/CHANGELOG.md export-ignore
12-
/CONDUCT.md export-ignore
13-
/phpunit.xml export-ignore
11+
/phpunit.xml.dist export-ignore
1412
/tests export-ignore

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ If the domain name or some of its part are seriously malformed or unrecognized,
128128
- `Pdp\Domain::isICANN` returns `true` if the public suffix is found in a selected PSL which includes the ICANN DOMAINS section;
129129
- `Pdp\Domain::isPrivate` returns `true` if the public suffix is found in a selected PSL which includes the PRIVATE DOMAINS section;
130130

131-
**THIS EXAMPLE ILLUSTRATES HOW EACH OBJECT IS USED BUT SHOULD BE AVOID IN A PRODUCTON**
131+
**THIS EXAMPLE ILLUSTRATES HOW EACH OBJECT IS USED BUT SHOULD BE AVOID IN PRODUCTON**
132132

133133
~~~php
134134
<?php
@@ -239,6 +239,12 @@ The package comes bundle with:
239239

240240
#### Refreshing the cached PSL
241241

242+
~~~php
243+
<?php
244+
245+
public Manager::refreshRules(string $source_url = self::PSL_URL): bool
246+
~~~
247+
242248
The `Pdp\Manager::refreshRules` method enables refreshing your local copy of the PSL stored with your [PSR-16](http://www.php-fig.org/psr/psr-16/) Cache and retrieved using the Http Client. By default the method will use the `Manager::PSL_URL` as the source URL but you are free to substitute this URL with your own.
243249
The method returns a boolean value which is `true` on success.
244250

@@ -263,7 +269,7 @@ if ($retval) {
263269
~~~php
264270
<?php
265271

266-
public function getRules(string $source_url = self::PSL_URL): Rules
272+
public Manager::getRules(string $source_url = self::PSL_URL): Rules
267273
~~~
268274

269275
This method returns a `Rules` object which is instantiated with the PSL rules.
@@ -314,6 +320,18 @@ This script requires:
314320
- The `Pdp\Installer` class which organizes how to update the cache.
315321
- The `Pdp\Cache` and `Pdp\CurlHttpClient` classes to retrieve and cache the PSL
316322

323+
You can also add a composer script in your `composer.json` file to update the PSL cache everytime after the `install` or the `update` command are executed.
324+
325+
~~~bash
326+
{
327+
"scripts": {
328+
"post-install-cmd": "\\Pdp\\Installer::updateLocalCache",
329+
"post-update-cmd": "\\Pdp\\Installer::updateLocalCache"
330+
}
331+
}
332+
~~~
333+
334+
317335
If you prefer using your own implementations you should:
318336

319337
1. Copy the `Pdp\Installer` class

tests/DomainTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
namespace pdp\tests;
66

7-
use Pdp\Cache;
8-
use Pdp\CurlHttpClient;
97
use Pdp\Domain;
10-
use Pdp\Manager;
118
use Pdp\PublicSuffix;
129
use Pdp\Rules;
1310
use PHPUnit\Framework\TestCase;
@@ -39,8 +36,7 @@ public function invalidRegistrableDomainProvider()
3936

4037
public function testDomainInternalPhpMethod()
4138
{
42-
$rules = (new Manager(new Cache(), new CurlHttpClient()))->getRules();
43-
$domain = $rules->resolve('contoso.com');
39+
$domain = new Domain('www.ulb.ac.be', new PublicSuffix('ac.be', Rules::ICANN_DOMAINS));
4440
$generateDomain = eval('return '.var_export($domain, true).';');
4541
$this->assertInternalType('array', $domain->__debugInfo());
4642
$this->assertEquals($domain, $generateDomain);

0 commit comments

Comments
 (0)