Skip to content

Commit c99d5cd

Browse files
committed
Grammar review
1 parent 982857c commit c99d5cd

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ Method | Description
8989
`setDrivers(array $drivers): void` | Set drivers used to download the resource
9090
`setOptions(string $key, mixed $value): void` | Set generic options
9191
`getOptions([string $key]): mixed` | Get generic options
92-
`setAllowUrls(array $urls): void` | Set allowed URLs
93-
`addAllowType(string $type, bool $binary): void` | Add content-type to the allowed list
94-
`removeAllowType(string $type): void` | Remove content-type from the allowed list
92+
`setAllowedUrls(array $urls): void` | Set allowed URLs
93+
`addAllowedType(string $type, bool $binary): void` | Add content-type to the allowed list
94+
`removeAllowedType(string $type): void` | Remove content-type from the allowed list
9595
`setTemporary(string $path): void` | Sets temporary handle path, eg.: `/mnt/storage/`, `php://temp`, `php://memory`
9696
`getTemporary(): resource` | Get temporary stream
9797
`download(string $url[, bool $ignoreDownloadError]): void` | Perform download
@@ -158,7 +158,7 @@ $proxy->setOptions('stream', [
158158
]);
159159
```
160160

161-
## Allow Content-Type
161+
## Content-Type allowed
162162

163163
When executing the download() method a content-type validation will be performed, by default the following Content-Types are allowed:
164164

@@ -176,16 +176,16 @@ Content-Type | `Proxy::jsonp()`
176176
You can define another allowed content-type, example:
177177

178178
```php
179-
$proxy->addAllowType('image/x-icon', true);
180-
$proxy->addAllowType('image/vnd.microsoft.icon', true);
179+
$proxy->addAllowedType('image/x-icon', true);
180+
$proxy->addAllowedType('image/vnd.microsoft.icon', true);
181181
```
182182

183183
Second parameter of the method specifies whether the `Proxy::jsonp()` should use URL encoding or Base64 encoding in the data URI scheme.
184184

185-
To remove an allowed Content-Type use the `Proxy::removeAllowType()` method, example:
185+
To remove an allowed Content-Type use the `Proxy::removeAllowedType()` method, example:
186186

187187
```php
188-
$proxy->removeAllowType('image/apng');
188+
$proxy->removeAllowedType('image/apng');
189189
```
190190

191191
## How to use
@@ -286,11 +286,11 @@ You can also limit the URLs that the proxy can access:
286286

287287
```php
288288
$proxy->urls([
289-
'https://domain1.com/', // Allow request in all paths from https://domain1.com
290-
'https://domain2.com/images/', // Allow requests in /images/ from https://domain2.com
291-
'https://*.mainsite.io/', // Allow requests in mainsite.com subdomain
292-
'https://foo.io:8000/', // Allow requests in other.io with port 8000
293-
'*://other.io/', // Allow HTTP or HTTPS requests in other.io
289+
'https://domain1.com/', // Allows requests on any path to https://domain1.com
290+
'https://domain2.com/images/', // Allows requests from the path /images/ on https://domain1.com
291+
'https://*.mainsite.io/', // Allows requests on subdomains of mainsite.io
292+
'https://foo.io:8000/', // Allows requests to foo.io with port 8000
293+
'*://other.io/', // Allows HTTPS and HTTP requests to other.io
294294
]);
295295

296296
$proxy->setTemporary('php://temp');

proxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
// Set allowed URLs
2121
/*
22-
$proxy->setAllowUrls([
22+
$proxy->setAllowedUrls([
2323
'https://*.domain.io/',
2424
'https://cdn.foobar.io/'
2525
]);
2626
*/
2727

2828
// Set allowed content-types
29-
// $proxy->addAllowType('image/ico', true);
29+
// $proxy->addAllowedType('image/ico', true);
3030

3131
// Extra configs for CurlDriver
3232
// $proxy->setOptions('curl', [ CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_3 ]);

src/Drivers/CurlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(Proxy $proxy)
3030
}
3131

3232
/**
33-
* Check driver available
33+
* Check if the driver is available
3434
*
3535
* @return bool
3636
*/

src/Drivers/InterfaceDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface InterfaceDriver
2222
public function __construct(Proxy $proxy);
2323

2424
/**
25-
* Check driver available
25+
* Check if the driver is available
2626
*
2727
* @return bool
2828
*/

src/Drivers/StreamDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(Proxy $proxy)
3030
}
3131

3232
/**
33-
* Check driver available
33+
* Check if the driver is available
3434
*
3535
* @return bool
3636
*/

src/Proxy.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class Proxy
2121
];
2222
private $driver;
2323
private $drivers = [];
24-
private $allowUrls = [];
25-
private $allowUrlsRegEx;
26-
private $allowTypes = [
24+
private $allowedUrls = [];
25+
private $allowedUrlsRegEx;
26+
private $allowedTypes = [
2727
'image/apng' => true,
2828
'image/png' => true,
2929
'image/avif' => true,
@@ -102,10 +102,10 @@ public function getOptions($key = null)
102102
* @param array $urls
103103
* @return void
104104
*/
105-
public function setAllowUrls(array $urls)
105+
public function setAllowedUrls(array $urls)
106106
{
107-
$this->allowUrls = $urls;
108-
$this->allowUrlsRegEx = null;
107+
$this->allowedUrls = $urls;
108+
$this->allowedUrlsRegEx = null;
109109
}
110110

111111
/**
@@ -115,9 +115,9 @@ public function setAllowUrls(array $urls)
115115
* @param string $binary
116116
* @return void
117117
*/
118-
public function addAllowType($type, $binary)
118+
public function addAllowedType($type, $binary)
119119
{
120-
$this->allowTypes[$type] = $binary;
120+
$this->allowedTypes[$type] = $binary;
121121
}
122122

123123
/**
@@ -126,9 +126,9 @@ public function addAllowType($type, $binary)
126126
* @param string $type
127127
* @return void
128128
*/
129-
public function removeAllowType($type)
129+
public function removeAllowedType($type)
130130
{
131-
unset($this->allowTypes[$type]);
131+
unset($this->allowedTypes[$type]);
132132
}
133133

134134
/**
@@ -206,7 +206,7 @@ public function download($url, $ignoreDownloadError = false)
206206
if ($selected) {
207207
$this->driver = $selected;
208208
} else {
209-
$this->raise('The selected drivers are not supported');
209+
$this->raise('None of the defined drivers are supported');
210210
}
211211
}
212212

@@ -218,8 +218,8 @@ public function download($url, $ignoreDownloadError = false)
218218
$contentType = trim($contentType);
219219
}
220220

221-
if (array_key_exists($contentType, $this->allowTypes) === false) {
222-
$this->raise('Not allowed Content-type: ' . $contentType);
221+
if (array_key_exists($contentType, $this->allowedTypes) === false) {
222+
$this->raise('The Content-Type header has the value ' . $contentType . ', which is not allowed');
223223
}
224224

225225
$this->contentType = $contentType;
@@ -301,7 +301,7 @@ public function jsonp($callback)
301301
list($contentType, $extra) = $extract;
302302
}
303303

304-
$binary = $this->allowTypes[$contentType];
304+
$binary = $this->allowedTypes[$contentType];
305305

306306
if ($binary) {
307307
$contentType .= ';base64';
@@ -429,21 +429,21 @@ private function httpCache()
429429

430430
private function validateUrl($url)
431431
{
432-
$urlList = $this->allowUrls;
432+
$urlList = $this->allowedUrls;
433433

434434
if ($urlList) {
435-
if ($this->allowUrlsRegEx === null) {
435+
if ($this->allowedUrlsRegEx === null) {
436436
$regex = implode('|', $urlList);
437437
$regex = preg_quote($regex, '#');
438438
$regex = strtr($regex, array(
439439
'\\*' => '\\w+',
440440
'\\|' => '|'
441441
));
442442

443-
$this->allowUrlsRegEx = '#^(' . $regex . ')#';
443+
$this->allowedUrlsRegEx = '#^(' . $regex . ')#';
444444
}
445445

446-
if (!preg_match($this->allowUrlsRegEx, $url)) {
446+
if (!preg_match($this->allowedUrlsRegEx, $url)) {
447447
return false;
448448
}
449449
}

0 commit comments

Comments
 (0)