Version Description
- 2021-02-25 =
- Enhancement - Scoped third-party vendor dependencies in order to avoid conflicts with other third-party vendor of other installed plugins
- Fix - Guzzle conflicts with other plugins
- Fix - Syntax error with PHP <7.4 versions
Download this release
Release Info
Developer | antoscarface |
Plugin | Pixel Caffeine |
Version | 2.3.1 |
Comparing to | |
See all releases |
Code changes from version 2.3.0 to 2.3.1
- includes/admin/class-aepc-facebook-adapter.php +2 -2
- includes/class-aepc-addon-factory.php +1 -1
- includes/class-aepc-addons-support.php +1 -1
- includes/class-aepc-track.php +2 -2
- includes/product-catalogs/class-product-catalogs.php +1 -1
- includes/product-catalogs/feed/class-xml-writer.php +1 -1
- includes/sdk/class-user-data-factory.php +2 -2
- includes/server-side/class-conversions-api.php +4 -5
- includes/server-side/class-event-factory.php +4 -4
- includes/server-side/class-pixel-event.php +1 -1
- includes/server-side/class-server-side-tracking.php +1 -3
- includes/supports/class-aepc-edd-addon-support.php +1 -1
- includes/supports/class-aepc-woocommerce-addon-support.php +1 -2
- languages/pixel-caffeine.pot +4 -4
- pixel-caffeine.php +3 -3
- readme.txt +5 -0
- third-party/vendor/a5hleyrich/wp-background-processing/classes/wp-async-request.php +181 -0
- third-party/vendor/a5hleyrich/wp-background-processing/classes/wp-background-process.php +505 -0
- {vendor → third-party/vendor}/a5hleyrich/wp-background-processing/license.txt +0 -0
- {vendor → third-party/vendor}/a5hleyrich/wp-background-processing/wp-background-processing.php +6 -2
- {vendor → third-party/vendor}/autoload.php +1 -1
- {vendor → third-party/vendor}/composer/ClassLoader.php +0 -0
- {vendor → third-party/vendor}/composer/LICENSE +0 -0
- third-party/vendor/composer/autoload_classmap.php +322 -0
- {vendor → third-party/vendor}/composer/autoload_namespaces.php +0 -0
- third-party/vendor/composer/autoload_psr4.php +9 -0
- third-party/vendor/composer/autoload_real.php +46 -0
- third-party/vendor/composer/autoload_static.php +332 -0
- third-party/vendor/composer/installed.json +1088 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/fb_ca_chain_bundle.crt +0 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/AnonymousSession.php +11 -10
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php +222 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/ApiConfig.php +8 -5
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/ApiRequest.php +207 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php +187 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Cursor.php +490 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Enum/AbstractEnum.php +165 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Enum/EmptyEnum.php +32 -31
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Enum/EnumInstanceInterface.php +81 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Exception/Exception.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AbstractAdapter.php +30 -31
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AdapterInterface.php +34 -40
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/AbstractCurl.php +130 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl.php +97 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl55.php +97 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/CurlInterface.php +93 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/CurlAdapter.php +166 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Client.php +197 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/AuthorizationException.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ClientException.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/EmptyResponseException.php +14 -17
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/PermissionException.php +4 -4
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php +211 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ServerException.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ThrottleException.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/FileParameter.php +62 -64
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Headers.php +4 -4
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Parameters.php +30 -32
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Request.php +271 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/RequestInterface.php +142 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Response.php +119 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/ResponseInterface.php +40 -48
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/SimpleRequest.php +63 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Util.php +22 -22
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger.php +238 -0
- vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php → third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonAwareParameters.php +12 -18
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonNode.php +173 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Logger/LoggerInterface.php +24 -29
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/NullLogger.php +55 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractArchivableCrudObject.php +79 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractCrudObject.php +488 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractObject.php +191 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixel.php +225 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStats.php +21 -24
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStatsResult.php +31 -34
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AbstractArchivableCrudObjectFields.php +7 -8
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelFields.php +57 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsFields.php +13 -20
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsResultFields.php +12 -18
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/ActionSource.php +37 -45
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php +194 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AsyncClient.php +18 -28
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/BatchProcessor.php +110 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Content.php +257 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/CustomData.php +514 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/DeliveryCategory.php +17 -20
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Event.php +426 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php +388 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequestAsync.php +63 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventResponse.php +213 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Gender.php +12 -16
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpMethod.php +9 -9
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceClientConfig.php +35 -33
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceInterface.php +13 -12
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php +287 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php +44 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/UserData.php +679 -0
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Util.php +137 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelAutomaticMatchingFieldsValues.php +16 -17
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelDataUseSettingValues.php +8 -9
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelFirstPartyCookieStatusValues.php +8 -9
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelSortByValues.php +7 -8
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelStatsResultAggregationValues.php +21 -22
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelTasksValues.php +7 -8
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Session.php +101 -0
- {vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/SessionInterface.php +8 -8
- third-party/vendor/facebook/php-business-sdk/src/FacebookAds/TypeChecker.php +204 -0
- {vendor → third-party/vendor}/firebase/php-jwt/package.xml +0 -0
- {vendor → third-party/vendor}/firebase/php-jwt/src/BeforeValidException.php +2 -2
- {vendor → third-party/vendor}/firebase/php-jwt/src/ExpiredException.php +2 -2
- {vendor → third-party/vendor}/firebase/php-jwt/src/JWT.php +69 -112
- {vendor → third-party/vendor}/firebase/php-jwt/src/SignatureInvalidException.php +2 -2
- third-party/vendor/guzzlehttp/guzzle/Dockerfile +18 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Client.php +128 -178
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/ClientInterface.php +19 -21
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/CookieJar.php +74 -141
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +14 -17
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +20 -37
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +15 -25
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/SetCookie.php +81 -148
- third-party/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +19 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +10 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +31 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +23 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php +7 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +147 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +25 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +10 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +7 -0
- third-party/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +7 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlFactory.php +102 -252
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +7 -6
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlHandler.php +7 -17
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +45 -121
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/EasyHandle.php +17 -68
- third-party/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +157 -0
- third-party/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +46 -0
- third-party/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +377 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/HandlerStack.php +72 -100
- third-party/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +156 -0
- third-party/vendor/guzzlehttp/guzzle/src/Middleware.php +221 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/Pool.php +33 -41
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +22 -35
- third-party/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +177 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/RequestOptions.php +32 -61
- third-party/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +99 -0
- {vendor → third-party/vendor}/guzzlehttp/guzzle/src/TransferStats.php +24 -47
- third-party/vendor/guzzlehttp/guzzle/src/UriTemplate.php +191 -0
- third-party/vendor/guzzlehttp/guzzle/src/Utils.php +82 -0
- third-party/vendor/guzzlehttp/guzzle/src/functions.php +294 -0
- third-party/vendor/guzzlehttp/guzzle/src/functions_include.php +8 -0
- {vendor → third-party/vendor}/guzzlehttp/promises/phpstan-baseline.neon +0 -0
- {vendor → third-party/vendor}/guzzlehttp/promises/psalm.xml +0 -0
- third-party/vendor/guzzlehttp/promises/src/AggregateException.php +14 -0
- third-party/vendor/guzzlehttp/promises/src/CancellationException.php +10 -0
- {vendor → third-party/vendor}/guzzlehttp/promises/src/Coroutine.php +13 -31
- {vendor → third-party/vendor}/guzzlehttp/promises/src/Create.php +11 -20
- {vendor → third-party/vendor}/guzzlehttp/promises/src/Each.php +12 -36
- {vendor → third-party/vendor}/guzzlehttp/promises/src/EachPromise.php +41 -87
- {vendor → third-party/vendor}/guzzlehttp/promises/src/FulfilledPromise.php +11 -26
- third-party/vendor/guzzlehttp/promises/src/Is.php +43 -0
- {vendor → third-party/vendor}/guzzlehttp/promises/src/Promise.php +33 -74
- {vendor → third-party/vendor}/guzzlehttp/promises/src/PromiseInterface.php +3 -13
- {vendor → third-party/vendor}/guzzlehttp/promises/src/PromisorInterface.php +1 -1
- {vendor → third-party/vendor}/guzzlehttp/promises/src/RejectedPromise.php +12 -28
- {vendor → third-party/vendor}/guzzlehttp/promises/src/RejectionException.php +3 -11
- {vendor → third-party/vendor}/guzzlehttp/promises/src/TaskQueue.php +9 -14
- {vendor → third-party/vendor}/guzzlehttp/promises/src/TaskQueueInterface.php +1 -3
- {vendor → third-party/vendor}/guzzlehttp/promises/src/Utils.php +42 -79
- {vendor → third-party/vendor}/guzzlehttp/promises/src/functions.php +33 -62
- third-party/vendor/guzzlehttp/promises/src/functions_include.php +8 -0
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/AppendStream.php +22 -63
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/BufferStream.php +15 -39
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/CachingStream.php +19 -43
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/DroppingStream.php +6 -13
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/FnStream.php +24 -51
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Header.php +10 -15
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/InflateStream.php +11 -16
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/LazyOpenStream.php +4 -9
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/LimitStream.php +14 -42
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Message.php +39 -94
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/MessageTrait.php +24 -67
- third-party/vendor/guzzlehttp/psr7/src/MimeType.php +33 -0
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/MultipartStream.php +20 -51
- third-party/vendor/guzzlehttp/psr7/src/NoSeekStream.php +20 -0
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/PumpStream.php +15 -42
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Query.php +21 -25
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Request.php +16 -48
- third-party/vendor/guzzlehttp/psr7/src/Response.php +76 -0
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Rfc7230.php +2 -2
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/ServerRequest.php +32 -106
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Stream.php +29 -76
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/StreamDecoratorTrait.php +8 -30
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/StreamWrapper.php +17 -77
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/UploadedFile.php +38 -111
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/Uri.php +62 -225
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/UriNormalizer.php +18 -56
- {vendor → third-party/vendor}/guzzlehttp/psr7/src/UriResolver.php +5 -9
includes/admin/class-aepc-facebook-adapter.php
CHANGED
@@ -9,10 +9,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
-
use Firebase\JWT\JWT;
|
13 |
use PixelCaffeine\Admin\Exception\FBAPIException;
|
14 |
use PixelCaffeine\Admin\Exception\FBAPILoginException;
|
15 |
-
use Ramsey\Uuid\Uuid;
|
16 |
use Symfony\Component\Yaml\Yaml;
|
17 |
|
18 |
/**
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
+
use PixelCaffeine\Dependencies\Firebase\JWT\JWT;
|
13 |
use PixelCaffeine\Admin\Exception\FBAPIException;
|
14 |
use PixelCaffeine\Admin\Exception\FBAPILoginException;
|
15 |
+
use PixelCaffeine\Dependencies\Ramsey\Uuid\Uuid;
|
16 |
use Symfony\Component\Yaml\Yaml;
|
17 |
|
18 |
/**
|
includes/class-aepc-addon-factory.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
-
use FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
10 |
use PixelCaffeine\ProductCatalog\Configuration;
|
11 |
use PixelCaffeine\ProductCatalog\ProductCatalogManager;
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
10 |
use PixelCaffeine\ProductCatalog\Configuration;
|
11 |
use PixelCaffeine\ProductCatalog\ProductCatalogManager;
|
includes/class-aepc-addons-support.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
-
use FacebookAds\Object\ServerSide\UserData;
|
9 |
|
10 |
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
exit; // Exit if accessed directly.
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
9 |
|
10 |
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
exit; // Exit if accessed directly.
|
includes/class-aepc-track.php
CHANGED
@@ -5,11 +5,11 @@
|
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
-
use FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\FB\User_Data_Factory;
|
10 |
use PixelCaffeine\ServerSide\Pixel_Event;
|
11 |
use PixelCaffeine\ServerSide\Server_Side_Tracking;
|
12 |
-
use Ramsey\Uuid\Uuid;
|
13 |
|
14 |
if ( ! defined( 'ABSPATH' ) ) {
|
15 |
exit; // Exit if accessed directly.
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\FB\User_Data_Factory;
|
10 |
use PixelCaffeine\ServerSide\Pixel_Event;
|
11 |
use PixelCaffeine\ServerSide\Server_Side_Tracking;
|
12 |
+
use PixelCaffeine\Dependencies\Ramsey\Uuid\Uuid;
|
13 |
|
14 |
if ( ! defined( 'ABSPATH' ) ) {
|
15 |
exit; // Exit if accessed directly.
|
includes/product-catalogs/class-product-catalogs.php
CHANGED
@@ -18,7 +18,7 @@ use PixelCaffeine\ProductCatalog\Entity\ProductCatalog as Entity;
|
|
18 |
use PixelCaffeine\ProductCatalog\Exception\FeedException;
|
19 |
use PixelCaffeine\ProductCatalog\Exception\GoogleTaxonomyException;
|
20 |
use PixelCaffeine\ProductCatalog\Feed\XMLWriter;
|
21 |
-
use Symfony\Component\Filesystem\Filesystem;
|
22 |
|
23 |
/**
|
24 |
* Manager class of Product Catalog feature
|
18 |
use PixelCaffeine\ProductCatalog\Exception\FeedException;
|
19 |
use PixelCaffeine\ProductCatalog\Exception\GoogleTaxonomyException;
|
20 |
use PixelCaffeine\ProductCatalog\Feed\XMLWriter;
|
21 |
+
use PixelCaffeine\Dependencies\Symfony\Component\Filesystem\Filesystem;
|
22 |
|
23 |
/**
|
24 |
* Manager class of Product Catalog feature
|
includes/product-catalogs/feed/class-xml-writer.php
CHANGED
@@ -15,7 +15,7 @@ use PixelCaffeine\ProductCatalog\Exception\FeedException;
|
|
15 |
use PixelCaffeine\ProductCatalog\FeedMapper;
|
16 |
use PixelCaffeine\ProductCatalog\Helper\FeedDirectoryHelper;
|
17 |
use PixelCaffeine\ProductCatalog\ProductCatalogManager;
|
18 |
-
use Symfony\Component\Filesystem\Filesystem;
|
19 |
|
20 |
/**
|
21 |
* Class XMLWriter
|
15 |
use PixelCaffeine\ProductCatalog\FeedMapper;
|
16 |
use PixelCaffeine\ProductCatalog\Helper\FeedDirectoryHelper;
|
17 |
use PixelCaffeine\ProductCatalog\ProductCatalogManager;
|
18 |
+
use PixelCaffeine\Dependencies\Symfony\Component\Filesystem\Filesystem;
|
19 |
|
20 |
/**
|
21 |
* Class XMLWriter
|
includes/sdk/class-user-data-factory.php
CHANGED
@@ -8,8 +8,8 @@
|
|
8 |
namespace PixelCaffeine\FB;
|
9 |
|
10 |
use AEPC_Addons_Support;
|
11 |
-
use FacebookAds\Object\ServerSide\UserData;
|
12 |
-
use FacebookAds\Object\ServerSide\Util;
|
13 |
|
14 |
/**
|
15 |
* Class User_Data_Factory
|
8 |
namespace PixelCaffeine\FB;
|
9 |
|
10 |
use AEPC_Addons_Support;
|
11 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
12 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util;
|
13 |
|
14 |
/**
|
15 |
* Class User_Data_Factory
|
includes/server-side/class-conversions-api.php
CHANGED
@@ -7,11 +7,10 @@
|
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
-
use FacebookAds\Api;
|
11 |
-
use FacebookAds\Exception\Exception as FacebookException;
|
12 |
-
use FacebookAds\Object\ServerSide\Event;
|
13 |
-
use FacebookAds\Object\ServerSide\EventRequest;
|
14 |
-
use PixelCaffeine\FB\ConnectorAdapter;
|
15 |
|
16 |
/**
|
17 |
* Class Conversions_API
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
11 |
+
use PixelCaffeine\Dependencies\FacebookAds\Exception\Exception as FacebookException;
|
12 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Event;
|
13 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\EventRequest;
|
|
|
14 |
|
15 |
/**
|
16 |
* Class Conversions_API
|
includes/server-side/class-event-factory.php
CHANGED
@@ -7,10 +7,10 @@
|
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
-
use FacebookAds\Object\ServerSide\ActionSource;
|
11 |
-
use FacebookAds\Object\ServerSide\CustomData;
|
12 |
-
use FacebookAds\Object\ServerSide\Event;
|
13 |
-
use FacebookAds\Object\ServerSide\Util;
|
14 |
use PixelCaffeine\FB\User_Data_Factory;
|
15 |
|
16 |
/**
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\ActionSource;
|
11 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\CustomData;
|
12 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Event;
|
13 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util;
|
14 |
use PixelCaffeine\FB\User_Data_Factory;
|
15 |
|
16 |
/**
|
includes/server-side/class-pixel-event.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
-
use FacebookAds\Object\ServerSide\UserData;
|
11 |
|
12 |
/**
|
13 |
* Class Pixel_Event
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
11 |
|
12 |
/**
|
13 |
* Class Pixel_Event
|
includes/server-side/class-server-side-tracking.php
CHANGED
@@ -7,9 +7,7 @@
|
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
-
use
|
11 |
-
use FacebookAds\Api;
|
12 |
-
use PixelCaffeine\FB\ConnectorAdapter;
|
13 |
|
14 |
/**
|
15 |
* Class Server_Side_Tracking
|
7 |
|
8 |
namespace PixelCaffeine\ServerSide;
|
9 |
|
10 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
|
|
|
|
11 |
|
12 |
/**
|
13 |
* Class Server_Side_Tracking
|
includes/supports/class-aepc-edd-addon-support.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
-
use FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\Interfaces\ECommerceAddOnInterface;
|
10 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
11 |
use PixelCaffeine\ProductCatalog\Configuration;
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
9 |
use PixelCaffeine\Interfaces\ECommerceAddOnInterface;
|
10 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
11 |
use PixelCaffeine\ProductCatalog\Configuration;
|
includes/supports/class-aepc-woocommerce-addon-support.php
CHANGED
@@ -5,8 +5,7 @@
|
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
-
use FacebookAds\Object\ServerSide\UserData;
|
9 |
-
use PixelCaffeine\FB\User_Data_Factory;
|
10 |
use PixelCaffeine\Interfaces\ECommerceAddOnInterface;
|
11 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
12 |
use PixelCaffeine\ProductCatalog\Configuration;
|
5 |
* @package Pixel Caffeine
|
6 |
*/
|
7 |
|
8 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\UserData;
|
|
|
9 |
use PixelCaffeine\Interfaces\ECommerceAddOnInterface;
|
10 |
use PixelCaffeine\ProductCatalog\Admin\Metaboxes;
|
11 |
use PixelCaffeine\ProductCatalog\Configuration;
|
languages/pixel-caffeine.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Pixel Caffeine package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Pixel Caffeine 2.3.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pixel-caffeine\n"
|
7 |
-
"POT-Creation-Date: 2021-02-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -142,7 +142,7 @@ msgstr ""
|
|
142 |
|
143 |
#: includes/admin/class-aepc-admin-ca.php:475
|
144 |
#: includes/admin/class-aepc-admin-view.php:1558
|
145 |
-
#: includes/admin/templates/parts/widgets/news.php:
|
146 |
#. translators: es. "2 minutes ago", "2 hours ago"
|
147 |
#. translators: %s: es. "2 minutes ago", "2 hours ago", etc.
|
148 |
#. translators: %s: human date diff (example: 2 days ago, 2 hours ago, etc.)
|
@@ -2770,7 +2770,7 @@ msgid ""
|
|
2770 |
"to track all your conversion events."
|
2771 |
msgstr ""
|
2772 |
|
2773 |
-
#: includes/admin/templates/parts/widgets/news.php:
|
2774 |
msgid "AdEspresso News"
|
2775 |
msgstr ""
|
2776 |
|
2 |
# This file is distributed under the same license as the Pixel Caffeine package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Pixel Caffeine 2.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pixel-caffeine\n"
|
7 |
+
"POT-Creation-Date: 2021-02-25 08:47:43+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
142 |
|
143 |
#: includes/admin/class-aepc-admin-ca.php:475
|
144 |
#: includes/admin/class-aepc-admin-view.php:1558
|
145 |
+
#: includes/admin/templates/parts/widgets/news.php:49
|
146 |
#. translators: es. "2 minutes ago", "2 hours ago"
|
147 |
#. translators: %s: es. "2 minutes ago", "2 hours ago", etc.
|
148 |
#. translators: %s: human date diff (example: 2 days ago, 2 hours ago, etc.)
|
2770 |
"to track all your conversion events."
|
2771 |
msgstr ""
|
2772 |
|
2773 |
+
#: includes/admin/templates/parts/widgets/news.php:34
|
2774 |
msgid "AdEspresso News"
|
2775 |
msgstr ""
|
2776 |
|
pixel-caffeine.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author URI: https://adespresso.com/
|
8 |
* Text Domain: pixel-caffeine
|
9 |
* Domain Path: /languages
|
10 |
-
* Version: 2.3.
|
11 |
* WC requires at least: 4.0.0
|
12 |
* WC tested up to: 5.0.0
|
13 |
*
|
@@ -33,7 +33,7 @@ if ( ! class_exists( 'PixelCaffeine' ) ) :
|
|
33 |
*
|
34 |
* @var string
|
35 |
*/
|
36 |
-
public $version = '2.3.
|
37 |
|
38 |
/**
|
39 |
* The single instance of the class.
|
@@ -121,7 +121,7 @@ if ( ! class_exists( 'PixelCaffeine' ) ) :
|
|
121 |
* @return void
|
122 |
*/
|
123 |
public function includes() {
|
124 |
-
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
|
125 |
|
126 |
// Include.
|
127 |
include_once dirname( __FILE__ ) . '/includes/functions-helpers.php';
|
7 |
* Author URI: https://adespresso.com/
|
8 |
* Text Domain: pixel-caffeine
|
9 |
* Domain Path: /languages
|
10 |
+
* Version: 2.3.1
|
11 |
* WC requires at least: 4.0.0
|
12 |
* WC tested up to: 5.0.0
|
13 |
*
|
33 |
*
|
34 |
* @var string
|
35 |
*/
|
36 |
+
public $version = '2.3.1';
|
37 |
|
38 |
/**
|
39 |
* The single instance of the class.
|
121 |
* @return void
|
122 |
*/
|
123 |
public function includes() {
|
124 |
+
require_once dirname( __FILE__ ) . '/third-party/vendor/scoper-autoload.php';
|
125 |
|
126 |
// Include.
|
127 |
include_once dirname( __FILE__ ) . '/includes/functions-helpers.php';
|
readme.txt
CHANGED
@@ -124,6 +124,11 @@ Unfortunately there isn’t any way at the moment to import custom audiences _fr
|
|
124 |
|
125 |
== Changelog ==
|
126 |
|
|
|
|
|
|
|
|
|
|
|
127 |
= 2.3.0 - 2021-02-18 =
|
128 |
* Support - **Dropping support to <7.2 PHP versions. It's now officially supported only 7.2+ PHP version (the plugin will continue to work with lower versions, but it might occur in some issues).**
|
129 |
* Add - Option to log all server side events sent from the server in "Logs" table
|
124 |
|
125 |
== Changelog ==
|
126 |
|
127 |
+
= 2.3.1 - 2021-02-25 =
|
128 |
+
* Enhancement - Scoped third-party vendor dependencies in order to avoid conflicts with other third-party vendor of other installed plugins
|
129 |
+
* Fix - Guzzle conflicts with other plugins
|
130 |
+
* Fix - Syntax error with PHP <7.4 versions
|
131 |
+
|
132 |
= 2.3.0 - 2021-02-18 =
|
133 |
* Support - **Dropping support to <7.2 PHP versions. It's now officially supported only 7.2+ PHP version (the plugin will continue to work with lower versions, but it might occur in some issues).**
|
134 |
* Add - Option to log all server side events sent from the server in "Logs" table
|
third-party/vendor/a5hleyrich/wp-background-processing/classes/wp-async-request.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP Async Request
|
4 |
+
*
|
5 |
+
* @package WP-Background-Processing
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Abstract WP_Async_Request class.
|
10 |
+
*
|
11 |
+
* @abstract
|
12 |
+
*/
|
13 |
+
abstract class WP_Async_Request {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Prefix
|
17 |
+
*
|
18 |
+
* (default value: 'wp')
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
* @access protected
|
22 |
+
*/
|
23 |
+
protected $prefix = 'wp';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Action
|
27 |
+
*
|
28 |
+
* (default value: 'async_request')
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
* @access protected
|
32 |
+
*/
|
33 |
+
protected $action = 'async_request';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Identifier
|
37 |
+
*
|
38 |
+
* @var mixed
|
39 |
+
* @access protected
|
40 |
+
*/
|
41 |
+
protected $identifier;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Data
|
45 |
+
*
|
46 |
+
* (default value: array())
|
47 |
+
*
|
48 |
+
* @var array
|
49 |
+
* @access protected
|
50 |
+
*/
|
51 |
+
protected $data = array();
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Initiate new async request
|
55 |
+
*/
|
56 |
+
public function __construct() {
|
57 |
+
$this->identifier = $this->prefix . '_' . $this->action;
|
58 |
+
|
59 |
+
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
60 |
+
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Set data used during the request
|
65 |
+
*
|
66 |
+
* @param array $data Data.
|
67 |
+
*
|
68 |
+
* @return $this
|
69 |
+
*/
|
70 |
+
public function data( $data ) {
|
71 |
+
$this->data = $data;
|
72 |
+
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Dispatch the async request
|
78 |
+
*
|
79 |
+
* @return array|WP_Error
|
80 |
+
*/
|
81 |
+
public function dispatch() {
|
82 |
+
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
83 |
+
$args = $this->get_post_args();
|
84 |
+
|
85 |
+
return wp_remote_post( esc_url_raw( $url ), $args );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get query args
|
90 |
+
*
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
protected function get_query_args() {
|
94 |
+
if ( property_exists( $this, 'query_args' ) ) {
|
95 |
+
return $this->query_args;
|
96 |
+
}
|
97 |
+
|
98 |
+
$args = array(
|
99 |
+
'action' => $this->identifier,
|
100 |
+
'nonce' => wp_create_nonce( $this->identifier ),
|
101 |
+
);
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Filters the post arguments used during an async request.
|
105 |
+
*
|
106 |
+
* @param array $url
|
107 |
+
*/
|
108 |
+
return apply_filters( $this->identifier . '_query_args', $args );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Get query URL
|
113 |
+
*
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
protected function get_query_url() {
|
117 |
+
if ( property_exists( $this, 'query_url' ) ) {
|
118 |
+
return $this->query_url;
|
119 |
+
}
|
120 |
+
|
121 |
+
$url = admin_url( 'admin-ajax.php' );
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Filters the post arguments used during an async request.
|
125 |
+
*
|
126 |
+
* @param string $url
|
127 |
+
*/
|
128 |
+
return apply_filters( $this->identifier . '_query_url', $url );
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get post args
|
133 |
+
*
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
protected function get_post_args() {
|
137 |
+
if ( property_exists( $this, 'post_args' ) ) {
|
138 |
+
return $this->post_args;
|
139 |
+
}
|
140 |
+
|
141 |
+
$args = array(
|
142 |
+
'timeout' => 0.01,
|
143 |
+
'blocking' => false,
|
144 |
+
'body' => $this->data,
|
145 |
+
'cookies' => $_COOKIE,
|
146 |
+
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
|
147 |
+
);
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Filters the post arguments used during an async request.
|
151 |
+
*
|
152 |
+
* @param array $args
|
153 |
+
*/
|
154 |
+
return apply_filters( $this->identifier . '_post_args', $args );
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Maybe handle
|
159 |
+
*
|
160 |
+
* Check for correct nonce and pass to handler.
|
161 |
+
*/
|
162 |
+
public function maybe_handle() {
|
163 |
+
// Don't lock up other requests while processing
|
164 |
+
session_write_close();
|
165 |
+
|
166 |
+
check_ajax_referer( $this->identifier, 'nonce' );
|
167 |
+
|
168 |
+
$this->handle();
|
169 |
+
|
170 |
+
wp_die();
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Handle
|
175 |
+
*
|
176 |
+
* Override this method to perform any actions required
|
177 |
+
* during the async request.
|
178 |
+
*/
|
179 |
+
abstract protected function handle();
|
180 |
+
|
181 |
+
}
|
third-party/vendor/a5hleyrich/wp-background-processing/classes/wp-background-process.php
ADDED
@@ -0,0 +1,505 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP Background Process
|
4 |
+
*
|
5 |
+
* @package WP-Background-Processing
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Abstract WP_Background_Process class.
|
10 |
+
*
|
11 |
+
* @abstract
|
12 |
+
* @extends WP_Async_Request
|
13 |
+
*/
|
14 |
+
abstract class WP_Background_Process extends WP_Async_Request {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Action
|
18 |
+
*
|
19 |
+
* (default value: 'background_process')
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
* @access protected
|
23 |
+
*/
|
24 |
+
protected $action = 'background_process';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Start time of current process.
|
28 |
+
*
|
29 |
+
* (default value: 0)
|
30 |
+
*
|
31 |
+
* @var int
|
32 |
+
* @access protected
|
33 |
+
*/
|
34 |
+
protected $start_time = 0;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Cron_hook_identifier
|
38 |
+
*
|
39 |
+
* @var mixed
|
40 |
+
* @access protected
|
41 |
+
*/
|
42 |
+
protected $cron_hook_identifier;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Cron_interval_identifier
|
46 |
+
*
|
47 |
+
* @var mixed
|
48 |
+
* @access protected
|
49 |
+
*/
|
50 |
+
protected $cron_interval_identifier;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Initiate new background process
|
54 |
+
*/
|
55 |
+
public function __construct() {
|
56 |
+
parent::__construct();
|
57 |
+
|
58 |
+
$this->cron_hook_identifier = $this->identifier . '_cron';
|
59 |
+
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
|
60 |
+
|
61 |
+
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
|
62 |
+
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Dispatch
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function dispatch() {
|
72 |
+
// Schedule the cron healthcheck.
|
73 |
+
$this->schedule_event();
|
74 |
+
|
75 |
+
// Perform remote post.
|
76 |
+
return parent::dispatch();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Push to queue
|
81 |
+
*
|
82 |
+
* @param mixed $data Data.
|
83 |
+
*
|
84 |
+
* @return $this
|
85 |
+
*/
|
86 |
+
public function push_to_queue( $data ) {
|
87 |
+
$this->data[] = $data;
|
88 |
+
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Save queue
|
94 |
+
*
|
95 |
+
* @return $this
|
96 |
+
*/
|
97 |
+
public function save() {
|
98 |
+
$key = $this->generate_key();
|
99 |
+
|
100 |
+
if ( ! empty( $this->data ) ) {
|
101 |
+
update_site_option( $key, $this->data );
|
102 |
+
}
|
103 |
+
|
104 |
+
return $this;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Update queue
|
109 |
+
*
|
110 |
+
* @param string $key Key.
|
111 |
+
* @param array $data Data.
|
112 |
+
*
|
113 |
+
* @return $this
|
114 |
+
*/
|
115 |
+
public function update( $key, $data ) {
|
116 |
+
if ( ! empty( $data ) ) {
|
117 |
+
update_site_option( $key, $data );
|
118 |
+
}
|
119 |
+
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Delete queue
|
125 |
+
*
|
126 |
+
* @param string $key Key.
|
127 |
+
*
|
128 |
+
* @return $this
|
129 |
+
*/
|
130 |
+
public function delete( $key ) {
|
131 |
+
delete_site_option( $key );
|
132 |
+
|
133 |
+
return $this;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Generate key
|
138 |
+
*
|
139 |
+
* Generates a unique key based on microtime. Queue items are
|
140 |
+
* given a unique key so that they can be merged upon save.
|
141 |
+
*
|
142 |
+
* @param int $length Length.
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
protected function generate_key( $length = 64 ) {
|
147 |
+
$unique = md5( microtime() . rand() );
|
148 |
+
$prepend = $this->identifier . '_batch_';
|
149 |
+
|
150 |
+
return substr( $prepend . $unique, 0, $length );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Maybe process queue
|
155 |
+
*
|
156 |
+
* Checks whether data exists within the queue and that
|
157 |
+
* the process is not already running.
|
158 |
+
*/
|
159 |
+
public function maybe_handle() {
|
160 |
+
// Don't lock up other requests while processing
|
161 |
+
session_write_close();
|
162 |
+
|
163 |
+
if ( $this->is_process_running() ) {
|
164 |
+
// Background process already running.
|
165 |
+
wp_die();
|
166 |
+
}
|
167 |
+
|
168 |
+
if ( $this->is_queue_empty() ) {
|
169 |
+
// No data to process.
|
170 |
+
wp_die();
|
171 |
+
}
|
172 |
+
|
173 |
+
check_ajax_referer( $this->identifier, 'nonce' );
|
174 |
+
|
175 |
+
$this->handle();
|
176 |
+
|
177 |
+
wp_die();
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Is queue empty
|
182 |
+
*
|
183 |
+
* @return bool
|
184 |
+
*/
|
185 |
+
protected function is_queue_empty() {
|
186 |
+
global $wpdb;
|
187 |
+
|
188 |
+
$table = $wpdb->options;
|
189 |
+
$column = 'option_name';
|
190 |
+
|
191 |
+
if ( is_multisite() ) {
|
192 |
+
$table = $wpdb->sitemeta;
|
193 |
+
$column = 'meta_key';
|
194 |
+
}
|
195 |
+
|
196 |
+
$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
|
197 |
+
|
198 |
+
$count = $wpdb->get_var( $wpdb->prepare( "
|
199 |
+
SELECT COUNT(*)
|
200 |
+
FROM {$table}
|
201 |
+
WHERE {$column} LIKE %s
|
202 |
+
", $key ) );
|
203 |
+
|
204 |
+
return ( $count > 0 ) ? false : true;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Is process running
|
209 |
+
*
|
210 |
+
* Check whether the current process is already running
|
211 |
+
* in a background process.
|
212 |
+
*/
|
213 |
+
protected function is_process_running() {
|
214 |
+
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
|
215 |
+
// Process already running.
|
216 |
+
return true;
|
217 |
+
}
|
218 |
+
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Lock process
|
224 |
+
*
|
225 |
+
* Lock the process so that multiple instances can't run simultaneously.
|
226 |
+
* Override if applicable, but the duration should be greater than that
|
227 |
+
* defined in the time_exceeded() method.
|
228 |
+
*/
|
229 |
+
protected function lock_process() {
|
230 |
+
$this->start_time = time(); // Set start time of current process.
|
231 |
+
|
232 |
+
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
|
233 |
+
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
|
234 |
+
|
235 |
+
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Unlock process
|
240 |
+
*
|
241 |
+
* Unlock the process so that other instances can spawn.
|
242 |
+
*
|
243 |
+
* @return $this
|
244 |
+
*/
|
245 |
+
protected function unlock_process() {
|
246 |
+
delete_site_transient( $this->identifier . '_process_lock' );
|
247 |
+
|
248 |
+
return $this;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Get batch
|
253 |
+
*
|
254 |
+
* @return stdClass Return the first batch from the queue
|
255 |
+
*/
|
256 |
+
protected function get_batch() {
|
257 |
+
global $wpdb;
|
258 |
+
|
259 |
+
$table = $wpdb->options;
|
260 |
+
$column = 'option_name';
|
261 |
+
$key_column = 'option_id';
|
262 |
+
$value_column = 'option_value';
|
263 |
+
|
264 |
+
if ( is_multisite() ) {
|
265 |
+
$table = $wpdb->sitemeta;
|
266 |
+
$column = 'meta_key';
|
267 |
+
$key_column = 'meta_id';
|
268 |
+
$value_column = 'meta_value';
|
269 |
+
}
|
270 |
+
|
271 |
+
$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
|
272 |
+
|
273 |
+
$query = $wpdb->get_row( $wpdb->prepare( "
|
274 |
+
SELECT *
|
275 |
+
FROM {$table}
|
276 |
+
WHERE {$column} LIKE %s
|
277 |
+
ORDER BY {$key_column} ASC
|
278 |
+
LIMIT 1
|
279 |
+
", $key ) );
|
280 |
+
|
281 |
+
$batch = new stdClass();
|
282 |
+
$batch->key = $query->$column;
|
283 |
+
$batch->data = maybe_unserialize( $query->$value_column );
|
284 |
+
|
285 |
+
return $batch;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Handle
|
290 |
+
*
|
291 |
+
* Pass each queue item to the task handler, while remaining
|
292 |
+
* within server memory and time limit constraints.
|
293 |
+
*/
|
294 |
+
protected function handle() {
|
295 |
+
$this->lock_process();
|
296 |
+
|
297 |
+
do {
|
298 |
+
$batch = $this->get_batch();
|
299 |
+
|
300 |
+
foreach ( $batch->data as $key => $value ) {
|
301 |
+
$task = $this->task( $value );
|
302 |
+
|
303 |
+
if ( false !== $task ) {
|
304 |
+
$batch->data[ $key ] = $task;
|
305 |
+
} else {
|
306 |
+
unset( $batch->data[ $key ] );
|
307 |
+
}
|
308 |
+
|
309 |
+
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
|
310 |
+
// Batch limits reached.
|
311 |
+
break;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
// Update or delete current batch.
|
316 |
+
if ( ! empty( $batch->data ) ) {
|
317 |
+
$this->update( $batch->key, $batch->data );
|
318 |
+
} else {
|
319 |
+
$this->delete( $batch->key );
|
320 |
+
}
|
321 |
+
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
|
322 |
+
|
323 |
+
$this->unlock_process();
|
324 |
+
|
325 |
+
// Start next batch or complete process.
|
326 |
+
if ( ! $this->is_queue_empty() ) {
|
327 |
+
$this->dispatch();
|
328 |
+
} else {
|
329 |
+
$this->complete();
|
330 |
+
}
|
331 |
+
|
332 |
+
wp_die();
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Memory exceeded
|
337 |
+
*
|
338 |
+
* Ensures the batch process never exceeds 90%
|
339 |
+
* of the maximum WordPress memory.
|
340 |
+
*
|
341 |
+
* @return bool
|
342 |
+
*/
|
343 |
+
protected function memory_exceeded() {
|
344 |
+
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
|
345 |
+
$current_memory = memory_get_usage( true );
|
346 |
+
$return = false;
|
347 |
+
|
348 |
+
if ( $current_memory >= $memory_limit ) {
|
349 |
+
$return = true;
|
350 |
+
}
|
351 |
+
|
352 |
+
return apply_filters( $this->identifier . '_memory_exceeded', $return );
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Get memory limit
|
357 |
+
*
|
358 |
+
* @return int
|
359 |
+
*/
|
360 |
+
protected function get_memory_limit() {
|
361 |
+
if ( function_exists( 'ini_get' ) ) {
|
362 |
+
$memory_limit = ini_get( 'memory_limit' );
|
363 |
+
} else {
|
364 |
+
// Sensible default.
|
365 |
+
$memory_limit = '128M';
|
366 |
+
}
|
367 |
+
|
368 |
+
if ( ! $memory_limit || - 1 === intval( $memory_limit ) ) {
|
369 |
+
// Unlimited, set to 32GB.
|
370 |
+
$memory_limit = '32000M';
|
371 |
+
}
|
372 |
+
|
373 |
+
return wp_convert_hr_to_bytes( $memory_limit );
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Time exceeded.
|
378 |
+
*
|
379 |
+
* Ensures the batch never exceeds a sensible time limit.
|
380 |
+
* A timeout limit of 30s is common on shared hosting.
|
381 |
+
*
|
382 |
+
* @return bool
|
383 |
+
*/
|
384 |
+
protected function time_exceeded() {
|
385 |
+
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
|
386 |
+
$return = false;
|
387 |
+
|
388 |
+
if ( time() >= $finish ) {
|
389 |
+
$return = true;
|
390 |
+
}
|
391 |
+
|
392 |
+
return apply_filters( $this->identifier . '_time_exceeded', $return );
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Complete.
|
397 |
+
*
|
398 |
+
* Override if applicable, but ensure that the below actions are
|
399 |
+
* performed, or, call parent::complete().
|
400 |
+
*/
|
401 |
+
protected function complete() {
|
402 |
+
// Unschedule the cron healthcheck.
|
403 |
+
$this->clear_scheduled_event();
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Schedule cron healthcheck
|
408 |
+
*
|
409 |
+
* @access public
|
410 |
+
*
|
411 |
+
* @param mixed $schedules Schedules.
|
412 |
+
*
|
413 |
+
* @return mixed
|
414 |
+
*/
|
415 |
+
public function schedule_cron_healthcheck( $schedules ) {
|
416 |
+
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
|
417 |
+
|
418 |
+
if ( property_exists( $this, 'cron_interval' ) ) {
|
419 |
+
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval );
|
420 |
+
}
|
421 |
+
|
422 |
+
// Adds every 5 minutes to the existing schedules.
|
423 |
+
$schedules[ $this->identifier . '_cron_interval' ] = array(
|
424 |
+
'interval' => MINUTE_IN_SECONDS * $interval,
|
425 |
+
'display' => sprintf( __( 'Every %d Minutes' ), $interval ),
|
426 |
+
);
|
427 |
+
|
428 |
+
return $schedules;
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Handle cron healthcheck
|
433 |
+
*
|
434 |
+
* Restart the background process if not already running
|
435 |
+
* and data exists in the queue.
|
436 |
+
*/
|
437 |
+
public function handle_cron_healthcheck() {
|
438 |
+
if ( $this->is_process_running() ) {
|
439 |
+
// Background process already running.
|
440 |
+
exit;
|
441 |
+
}
|
442 |
+
|
443 |
+
if ( $this->is_queue_empty() ) {
|
444 |
+
// No data to process.
|
445 |
+
$this->clear_scheduled_event();
|
446 |
+
exit;
|
447 |
+
}
|
448 |
+
|
449 |
+
$this->handle();
|
450 |
+
|
451 |
+
exit;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Schedule event
|
456 |
+
*/
|
457 |
+
protected function schedule_event() {
|
458 |
+
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
|
459 |
+
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Clear scheduled event
|
465 |
+
*/
|
466 |
+
protected function clear_scheduled_event() {
|
467 |
+
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
|
468 |
+
|
469 |
+
if ( $timestamp ) {
|
470 |
+
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Cancel Process
|
476 |
+
*
|
477 |
+
* Stop processing queue items, clear cronjob and delete batch.
|
478 |
+
*
|
479 |
+
*/
|
480 |
+
public function cancel_process() {
|
481 |
+
if ( ! $this->is_queue_empty() ) {
|
482 |
+
$batch = $this->get_batch();
|
483 |
+
|
484 |
+
$this->delete( $batch->key );
|
485 |
+
|
486 |
+
wp_clear_scheduled_hook( $this->cron_hook_identifier );
|
487 |
+
}
|
488 |
+
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Task
|
493 |
+
*
|
494 |
+
* Override this method to perform any actions required on each
|
495 |
+
* queue item. Return the modified item for further processing
|
496 |
+
* in the next pass through. Or, return false to remove the
|
497 |
+
* item from the queue.
|
498 |
+
*
|
499 |
+
* @param mixed $item Queue item to iterate over.
|
500 |
+
*
|
501 |
+
* @return mixed
|
502 |
+
*/
|
503 |
+
abstract protected function task( $item );
|
504 |
+
|
505 |
+
}
|
{vendor → third-party/vendor}/a5hleyrich/wp-background-processing/license.txt
RENAMED
File without changes
|
{vendor → third-party/vendor}/a5hleyrich/wp-background-processing/wp-background-processing.php
RENAMED
@@ -16,5 +16,9 @@ GitHub Plugin URI: https://github.com/A5hleyRich/wp-background-processing
|
|
16 |
GitHub Branch: master
|
17 |
*/
|
18 |
|
19 |
-
|
20 |
-
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-
|
|
|
|
|
|
|
|
16 |
GitHub Branch: master
|
17 |
*/
|
18 |
|
19 |
+
if ( ! class_exists( 'WP_Async_Request' ) ) {
|
20 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php';
|
21 |
+
}
|
22 |
+
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
23 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php';
|
24 |
+
}
|
{vendor → third-party/vendor}/autoload.php
RENAMED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144::getLoader();
|
{vendor → third-party/vendor}/composer/ClassLoader.php
RENAMED
File without changes
|
{vendor → third-party/vendor}/composer/LICENSE
RENAMED
File without changes
|
third-party/vendor/composer/autoload_classmap.php
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_classmap.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'AEPC_Addon_Factory' => $baseDir . '/../includes/class-aepc-addon-factory.php',
|
10 |
+
'AEPC_Addon_Product_Item' => $baseDir . '/../includes/class-aepc-addon-product-item.php',
|
11 |
+
'AEPC_Addons_Support' => $baseDir . '/../includes/class-aepc-addons-support.php',
|
12 |
+
'AEPC_Admin' => $baseDir . '/../includes/admin/class-aepc-admin.php',
|
13 |
+
'AEPC_Admin_Ajax' => $baseDir . '/../includes/admin/class-aepc-admin-ajax.php',
|
14 |
+
'AEPC_Admin_CA' => $baseDir . '/../includes/admin/class-aepc-admin-ca.php',
|
15 |
+
'AEPC_Admin_CA_Manager' => $baseDir . '/../includes/admin/class-aepc-admin-ca-manager.php',
|
16 |
+
'AEPC_Admin_Handlers' => $baseDir . '/../includes/admin/class-aepc-admin-handlers.php',
|
17 |
+
'AEPC_Admin_Install' => $baseDir . '/../includes/admin/class-aepc-admin-install.php',
|
18 |
+
'AEPC_Admin_Logger' => $baseDir . '/../includes/admin/class-aepc-admin-logger.php',
|
19 |
+
'AEPC_Admin_Menu' => $baseDir . '/../includes/admin/class-aepc-admin-menu.php',
|
20 |
+
'AEPC_Admin_Notices' => $baseDir . '/../includes/admin/class-aepc-admin-notices.php',
|
21 |
+
'AEPC_Admin_Response' => $baseDir . '/../includes/admin/class-aepc-admin-response.php',
|
22 |
+
'AEPC_Admin_View' => $baseDir . '/../includes/admin/class-aepc-admin-view.php',
|
23 |
+
'AEPC_Cron' => $baseDir . '/../includes/class-aepc-cron.php',
|
24 |
+
'AEPC_Currency' => $baseDir . '/../includes/class-aepc-currency.php',
|
25 |
+
'AEPC_Edd_Addon_Support' => $baseDir . '/../includes/supports/class-aepc-edd-addon-support.php',
|
26 |
+
'AEPC_Facebook_Adapter' => $baseDir . '/../includes/admin/class-aepc-facebook-adapter.php',
|
27 |
+
'AEPC_Pixel_Scripts' => $baseDir . '/../includes/class-aepc-pixel-scripts.php',
|
28 |
+
'AEPC_Third_Party_Fixes' => $baseDir . '/../includes/aepc-third-party-fixes.php',
|
29 |
+
'AEPC_Track' => $baseDir . '/../includes/class-aepc-track.php',
|
30 |
+
'AEPC_Woocommerce_Addon_Support' => $baseDir . '/../includes/supports/class-aepc-woocommerce-addon-support.php',
|
31 |
+
'PixelCaffeine\\Admin\\Exception\\AEPCException' => $baseDir . '/../includes/admin/exceptions/exception-aepc-exception.php',
|
32 |
+
'PixelCaffeine\\Admin\\Exception\\FBAPIException' => $baseDir . '/../includes/admin/exceptions/exception-fbapi.php',
|
33 |
+
'PixelCaffeine\\Admin\\Exception\\FBAPILoginException' => $baseDir . '/../includes/admin/exceptions/exception-fbapi-login.php',
|
34 |
+
'PixelCaffeine\\Dependencies\\ArithmeticError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php',
|
35 |
+
'PixelCaffeine\\Dependencies\\AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php',
|
36 |
+
'PixelCaffeine\\Dependencies\\ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144' => $vendorDir . '/composer/autoload_real.php',
|
37 |
+
'PixelCaffeine\\Dependencies\\Composer\\Autoload\\ClassLoader' => $vendorDir . '/composer/ClassLoader.php',
|
38 |
+
'PixelCaffeine\\Dependencies\\Composer\\Autoload\\ComposerStaticInit2794c148e8d4f809de17342ff307f144' => $vendorDir . '/composer/autoload_static.php',
|
39 |
+
'PixelCaffeine\\Dependencies\\DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php',
|
40 |
+
'PixelCaffeine\\Dependencies\\Error' => $vendorDir . '/paragonie/random_compat/lib/error_polyfill.php',
|
41 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\AnonymousSession' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/AnonymousSession.php',
|
42 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Api' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Api.php',
|
43 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\ApiConfig' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/ApiConfig.php',
|
44 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\ApiRequest' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/ApiRequest.php',
|
45 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\CrashReasons' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php',
|
46 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\CrashReporter' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php',
|
47 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Cursor' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Cursor.php',
|
48 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\AbstractEnum' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Enum/AbstractEnum.php',
|
49 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\EmptyEnum' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Enum/EmptyEnum.php',
|
50 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\EnumInstanceInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Enum/EnumInstanceInterface.php',
|
51 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Exception\\Exception' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Exception/Exception.php',
|
52 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\AbstractAdapter' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AbstractAdapter.php',
|
53 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\AdapterInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AdapterInterface.php',
|
54 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\CurlAdapter' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/CurlAdapter.php',
|
55 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\AbstractCurl' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/AbstractCurl.php',
|
56 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\Curl' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl.php',
|
57 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\Curl55' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl55.php',
|
58 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\CurlInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/CurlInterface.php',
|
59 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Client' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Client.php',
|
60 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\AuthorizationException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/AuthorizationException.php',
|
61 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ClientException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ClientException.php',
|
62 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\EmptyResponseException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/EmptyResponseException.php',
|
63 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\PermissionException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/PermissionException.php',
|
64 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\RequestException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php',
|
65 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ServerException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ServerException.php',
|
66 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ThrottleException' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ThrottleException.php',
|
67 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\FileParameter' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/FileParameter.php',
|
68 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Headers' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Headers.php',
|
69 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Parameters' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Parameters.php',
|
70 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Request' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Request.php',
|
71 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\RequestInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/RequestInterface.php',
|
72 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Response' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Response.php',
|
73 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\ResponseInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/ResponseInterface.php',
|
74 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\SimpleRequest' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/SimpleRequest.php',
|
75 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Util' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Http/Util.php',
|
76 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger.php',
|
77 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger\\JsonAwareParameters' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonAwareParameters.php',
|
78 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger\\JsonNode' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonNode.php',
|
79 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\LoggerInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Logger/LoggerInterface.php',
|
80 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\NullLogger' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Logger/NullLogger.php',
|
81 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractArchivableCrudObject' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractArchivableCrudObject.php',
|
82 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractCrudObject' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractCrudObject.php',
|
83 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractObject' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractObject.php',
|
84 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixel' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixel.php',
|
85 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixelStats' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStats.php',
|
86 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixelStatsResult' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStatsResult.php',
|
87 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AbstractArchivableCrudObjectFields' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AbstractArchivableCrudObjectFields.php',
|
88 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelFields' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelFields.php',
|
89 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelStatsFields' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsFields.php',
|
90 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelStatsResultFields' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsResultFields.php',
|
91 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\ActionSource' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/ActionSource.php',
|
92 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\AdsPixelSettings' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php',
|
93 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\AsyncClient' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AsyncClient.php',
|
94 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\BatchProcessor' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/BatchProcessor.php',
|
95 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Content' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Content.php',
|
96 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\CustomData' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/CustomData.php',
|
97 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\DeliveryCategory' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/DeliveryCategory.php',
|
98 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Event' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Event.php',
|
99 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventRequest' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php',
|
100 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventRequestAsync' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequestAsync.php',
|
101 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventResponse' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventResponse.php',
|
102 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Gender' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Gender.php',
|
103 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpMethod' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpMethod.php',
|
104 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpServiceClientConfig' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceClientConfig.php',
|
105 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpServiceInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceInterface.php',
|
106 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Normalizer' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php',
|
107 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Singleton' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php',
|
108 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\UserData' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/UserData.php',
|
109 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Util' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Util.php',
|
110 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelAutomaticMatchingFieldsValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelAutomaticMatchingFieldsValues.php',
|
111 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelDataUseSettingValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelDataUseSettingValues.php',
|
112 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelFirstPartyCookieStatusValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelFirstPartyCookieStatusValues.php',
|
113 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelSortByValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelSortByValues.php',
|
114 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelStatsResultAggregationValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelStatsResultAggregationValues.php',
|
115 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelTasksValues' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelTasksValues.php',
|
116 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Session' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/Session.php',
|
117 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\SessionInterface' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/SessionInterface.php',
|
118 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\TypeChecker' => $vendorDir . '/facebook/php-business-sdk/src/FacebookAds/TypeChecker.php',
|
119 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\BeforeValidException' => $vendorDir . '/firebase/php-jwt/src/BeforeValidException.php',
|
120 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\ExpiredException' => $vendorDir . '/firebase/php-jwt/src/ExpiredException.php',
|
121 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\JWT' => $vendorDir . '/firebase/php-jwt/src/JWT.php',
|
122 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/src/SignatureInvalidException.php',
|
123 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Client' => $vendorDir . '/guzzlehttp/guzzle/src/Client.php',
|
124 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\ClientInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ClientInterface.php',
|
125 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\CookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
|
126 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\CookieJarInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
|
127 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\FileCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
|
128 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\SessionCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
|
129 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\SetCookie' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
|
130 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\BadResponseException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
|
131 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ClientException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
|
132 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ConnectException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
|
133 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\GuzzleException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/GuzzleException.php',
|
134 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\InvalidArgumentException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php',
|
135 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\RequestException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
|
136 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\SeekException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/SeekException.php',
|
137 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ServerException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
|
138 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\TooManyRedirectsException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
|
139 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\TransferException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
|
140 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\HandlerStack' => $vendorDir . '/guzzlehttp/guzzle/src/HandlerStack.php',
|
141 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlFactory' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlFactory.php',
|
142 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlFactoryInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php',
|
143 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlHandler.php',
|
144 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlMultiHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php',
|
145 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\EasyHandle' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/EasyHandle.php',
|
146 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\MockHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/MockHandler.php',
|
147 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\Proxy' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/Proxy.php',
|
148 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\StreamHandler' => $vendorDir . '/guzzlehttp/guzzle/src/Handler/StreamHandler.php',
|
149 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\MessageFormatter' => $vendorDir . '/guzzlehttp/guzzle/src/MessageFormatter.php',
|
150 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Middleware' => $vendorDir . '/guzzlehttp/guzzle/src/Middleware.php',
|
151 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Pool' => $vendorDir . '/guzzlehttp/guzzle/src/Pool.php',
|
152 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\PrepareBodyMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php',
|
153 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\AggregateException' => $vendorDir . '/guzzlehttp/promises/src/AggregateException.php',
|
154 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\CancellationException' => $vendorDir . '/guzzlehttp/promises/src/CancellationException.php',
|
155 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Coroutine' => $vendorDir . '/guzzlehttp/promises/src/Coroutine.php',
|
156 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Create' => $vendorDir . '/guzzlehttp/promises/src/Create.php',
|
157 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Each' => $vendorDir . '/guzzlehttp/promises/src/Each.php',
|
158 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\EachPromise' => $vendorDir . '/guzzlehttp/promises/src/EachPromise.php',
|
159 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\FulfilledPromise' => $vendorDir . '/guzzlehttp/promises/src/FulfilledPromise.php',
|
160 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Is' => $vendorDir . '/guzzlehttp/promises/src/Is.php',
|
161 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Promise' => $vendorDir . '/guzzlehttp/promises/src/Promise.php',
|
162 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\PromiseInterface' => $vendorDir . '/guzzlehttp/promises/src/PromiseInterface.php',
|
163 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\PromisorInterface' => $vendorDir . '/guzzlehttp/promises/src/PromisorInterface.php',
|
164 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\RejectedPromise' => $vendorDir . '/guzzlehttp/promises/src/RejectedPromise.php',
|
165 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\RejectionException' => $vendorDir . '/guzzlehttp/promises/src/RejectionException.php',
|
166 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\TaskQueue' => $vendorDir . '/guzzlehttp/promises/src/TaskQueue.php',
|
167 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\TaskQueueInterface' => $vendorDir . '/guzzlehttp/promises/src/TaskQueueInterface.php',
|
168 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Utils' => $vendorDir . '/guzzlehttp/promises/src/Utils.php',
|
169 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\AppendStream' => $vendorDir . '/guzzlehttp/psr7/src/AppendStream.php',
|
170 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\BufferStream' => $vendorDir . '/guzzlehttp/psr7/src/BufferStream.php',
|
171 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\CachingStream' => $vendorDir . '/guzzlehttp/psr7/src/CachingStream.php',
|
172 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\DroppingStream' => $vendorDir . '/guzzlehttp/psr7/src/DroppingStream.php',
|
173 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\FnStream' => $vendorDir . '/guzzlehttp/psr7/src/FnStream.php',
|
174 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Header' => $vendorDir . '/guzzlehttp/psr7/src/Header.php',
|
175 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\InflateStream' => $vendorDir . '/guzzlehttp/psr7/src/InflateStream.php',
|
176 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\LazyOpenStream' => $vendorDir . '/guzzlehttp/psr7/src/LazyOpenStream.php',
|
177 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\LimitStream' => $vendorDir . '/guzzlehttp/psr7/src/LimitStream.php',
|
178 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Message' => $vendorDir . '/guzzlehttp/psr7/src/Message.php',
|
179 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MessageTrait' => $vendorDir . '/guzzlehttp/psr7/src/MessageTrait.php',
|
180 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MimeType' => $vendorDir . '/guzzlehttp/psr7/src/MimeType.php',
|
181 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MultipartStream' => $vendorDir . '/guzzlehttp/psr7/src/MultipartStream.php',
|
182 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\NoSeekStream' => $vendorDir . '/guzzlehttp/psr7/src/NoSeekStream.php',
|
183 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\PumpStream' => $vendorDir . '/guzzlehttp/psr7/src/PumpStream.php',
|
184 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Query' => $vendorDir . '/guzzlehttp/psr7/src/Query.php',
|
185 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Request' => $vendorDir . '/guzzlehttp/psr7/src/Request.php',
|
186 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Response' => $vendorDir . '/guzzlehttp/psr7/src/Response.php',
|
187 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Rfc7230' => $vendorDir . '/guzzlehttp/psr7/src/Rfc7230.php',
|
188 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\ServerRequest' => $vendorDir . '/guzzlehttp/psr7/src/ServerRequest.php',
|
189 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Stream' => $vendorDir . '/guzzlehttp/psr7/src/Stream.php',
|
190 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\StreamDecoratorTrait' => $vendorDir . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
|
191 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\StreamWrapper' => $vendorDir . '/guzzlehttp/psr7/src/StreamWrapper.php',
|
192 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UploadedFile' => $vendorDir . '/guzzlehttp/psr7/src/UploadedFile.php',
|
193 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Uri' => $vendorDir . '/guzzlehttp/psr7/src/Uri.php',
|
194 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UriNormalizer' => $vendorDir . '/guzzlehttp/psr7/src/UriNormalizer.php',
|
195 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UriResolver' => $vendorDir . '/guzzlehttp/psr7/src/UriResolver.php',
|
196 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Utils' => $vendorDir . '/guzzlehttp/psr7/src/Utils.php',
|
197 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RedirectMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/RedirectMiddleware.php',
|
198 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RequestOptions' => $vendorDir . '/guzzlehttp/guzzle/src/RequestOptions.php',
|
199 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RetryMiddleware' => $vendorDir . '/guzzlehttp/guzzle/src/RetryMiddleware.php',
|
200 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\TransferStats' => $vendorDir . '/guzzlehttp/guzzle/src/TransferStats.php',
|
201 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\UriTemplate' => $vendorDir . '/guzzlehttp/guzzle/src/UriTemplate.php',
|
202 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Utils' => $vendorDir . '/guzzlehttp/guzzle/src/Utils.php',
|
203 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\DownloadsParser' => $vendorDir . '/civicrm/composer-downloads-plugin/src/DownloadsParser.php',
|
204 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\GlobCleaner' => $vendorDir . '/civicrm/composer-downloads-plugin/src/GlobCleaner.php',
|
205 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\ArchiveHandler' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Handler/ArchiveHandler.php',
|
206 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\BaseHandler' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Handler/BaseHandler.php',
|
207 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\FileHandler' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Handler/FileHandler.php',
|
208 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\PharHandler' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Handler/PharHandler.php',
|
209 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Plugin' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Plugin.php',
|
210 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Subpackage' => $vendorDir . '/civicrm/composer-downloads-plugin/src/Subpackage.php',
|
211 |
+
'PixelCaffeine\\Dependencies\\Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
212 |
+
'PixelCaffeine\\Dependencies\\ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php',
|
213 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\MessageInterface' => $vendorDir . '/psr/http-message/src/MessageInterface.php',
|
214 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\RequestInterface' => $vendorDir . '/psr/http-message/src/RequestInterface.php',
|
215 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\ResponseInterface' => $vendorDir . '/psr/http-message/src/ResponseInterface.php',
|
216 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\ServerRequestInterface' => $vendorDir . '/psr/http-message/src/ServerRequestInterface.php',
|
217 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\StreamInterface' => $vendorDir . '/psr/http-message/src/StreamInterface.php',
|
218 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\UploadedFileInterface' => $vendorDir . '/psr/http-message/src/UploadedFileInterface.php',
|
219 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\UriInterface' => $vendorDir . '/psr/http-message/src/UriInterface.php',
|
220 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\BinaryUtils' => $vendorDir . '/ramsey/uuid/src/BinaryUtils.php',
|
221 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php',
|
222 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php',
|
223 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\UuidBuilderInterface' => $vendorDir . '/ramsey/uuid/src/Builder/UuidBuilderInterface.php',
|
224 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\CodecInterface' => $vendorDir . '/ramsey/uuid/src/Codec/CodecInterface.php',
|
225 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\GuidStringCodec' => $vendorDir . '/ramsey/uuid/src/Codec/GuidStringCodec.php',
|
226 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\OrderedTimeCodec' => $vendorDir . '/ramsey/uuid/src/Codec/OrderedTimeCodec.php',
|
227 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\StringCodec' => $vendorDir . '/ramsey/uuid/src/Codec/StringCodec.php',
|
228 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\TimestampFirstCombCodec' => $vendorDir . '/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php',
|
229 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\TimestampLastCombCodec' => $vendorDir . '/ramsey/uuid/src/Codec/TimestampLastCombCodec.php',
|
230 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\NumberConverterInterface' => $vendorDir . '/ramsey/uuid/src/Converter/NumberConverterInterface.php',
|
231 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Number\\BigNumberConverter' => $vendorDir . '/ramsey/uuid/src/Converter/Number/BigNumberConverter.php',
|
232 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Number\\DegradedNumberConverter' => $vendorDir . '/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php',
|
233 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\TimeConverterInterface' => $vendorDir . '/ramsey/uuid/src/Converter/TimeConverterInterface.php',
|
234 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\BigNumberTimeConverter' => $vendorDir . '/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php',
|
235 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\DegradedTimeConverter' => $vendorDir . '/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php',
|
236 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\PhpTimeConverter' => $vendorDir . '/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php',
|
237 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\DegradedUuid' => $vendorDir . '/ramsey/uuid/src/DegradedUuid.php',
|
238 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\InvalidUuidStringException' => $vendorDir . '/ramsey/uuid/src/Exception/InvalidUuidStringException.php',
|
239 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\UnsatisfiedDependencyException' => $vendorDir . '/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php',
|
240 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\UnsupportedOperationException' => $vendorDir . '/ramsey/uuid/src/Exception/UnsupportedOperationException.php',
|
241 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\FeatureSet' => $vendorDir . '/ramsey/uuid/src/FeatureSet.php',
|
242 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\CombGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/CombGenerator.php',
|
243 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\DefaultTimeGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/DefaultTimeGenerator.php',
|
244 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\MtRandGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/MtRandGenerator.php',
|
245 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\OpenSslGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/OpenSslGenerator.php',
|
246 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\PeclUuidRandomGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php',
|
247 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\PeclUuidTimeGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php',
|
248 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomBytesGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/RandomBytesGenerator.php',
|
249 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomGeneratorFactory' => $vendorDir . '/ramsey/uuid/src/Generator/RandomGeneratorFactory.php',
|
250 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomGeneratorInterface' => $vendorDir . '/ramsey/uuid/src/Generator/RandomGeneratorInterface.php',
|
251 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomLibAdapter' => $vendorDir . '/ramsey/uuid/src/Generator/RandomLibAdapter.php',
|
252 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\SodiumRandomGenerator' => $vendorDir . '/ramsey/uuid/src/Generator/SodiumRandomGenerator.php',
|
253 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\TimeGeneratorFactory' => $vendorDir . '/ramsey/uuid/src/Generator/TimeGeneratorFactory.php',
|
254 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\TimeGeneratorInterface' => $vendorDir . '/ramsey/uuid/src/Generator/TimeGeneratorInterface.php',
|
255 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\NodeProviderInterface' => $vendorDir . '/ramsey/uuid/src/Provider/NodeProviderInterface.php',
|
256 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\FallbackNodeProvider' => $vendorDir . '/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php',
|
257 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\RandomNodeProvider' => $vendorDir . '/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php',
|
258 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\SystemNodeProvider' => $vendorDir . '/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php',
|
259 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\TimeProviderInterface' => $vendorDir . '/ramsey/uuid/src/Provider/TimeProviderInterface.php',
|
260 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Time\\FixedTimeProvider' => $vendorDir . '/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php',
|
261 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Time\\SystemTimeProvider' => $vendorDir . '/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php',
|
262 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Uuid' => $vendorDir . '/ramsey/uuid/src/Uuid.php',
|
263 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidFactory' => $vendorDir . '/ramsey/uuid/src/UuidFactory.php',
|
264 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidFactoryInterface' => $vendorDir . '/ramsey/uuid/src/UuidFactoryInterface.php',
|
265 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidInterface' => $vendorDir . '/ramsey/uuid/src/UuidInterface.php',
|
266 |
+
'PixelCaffeine\\Dependencies\\SessionUpdateTimestampHandlerInterface' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php',
|
267 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/filesystem/Exception/ExceptionInterface.php',
|
268 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\FileNotFoundException' => $vendorDir . '/symfony/filesystem/Exception/FileNotFoundException.php',
|
269 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\IOException' => $vendorDir . '/symfony/filesystem/Exception/IOException.php',
|
270 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\IOExceptionInterface' => $vendorDir . '/symfony/filesystem/Exception/IOExceptionInterface.php',
|
271 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Filesystem' => $vendorDir . '/symfony/filesystem/Filesystem.php',
|
272 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\LockHandler' => $vendorDir . '/symfony/filesystem/LockHandler.php',
|
273 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
|
274 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Idn' => $vendorDir . '/symfony/polyfill-intl-idn/Idn.php',
|
275 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Info' => $vendorDir . '/symfony/polyfill-intl-idn/Info.php',
|
276 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Resources\\unidata\\DisallowedRanges' => $vendorDir . '/symfony/polyfill-intl-idn/Resources/unidata/DisallowedRanges.php',
|
277 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Resources\\unidata\\Regex' => $vendorDir . '/symfony/polyfill-intl-idn/Resources/unidata/Regex.php',
|
278 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Normalizer\\Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Normalizer.php',
|
279 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php70\\Php70' => $vendorDir . '/symfony/polyfill-php70/Php70.php',
|
280 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php72\\Php72' => $vendorDir . '/symfony/polyfill-php72/Php72.php',
|
281 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_FileFinder' => $vendorDir . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/FileFinder.php',
|
282 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Pattern' => $vendorDir . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Pattern.php',
|
283 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Rule' => $vendorDir . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Rule.php',
|
284 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Ruleset' => $vendorDir . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Ruleset.php',
|
285 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Util' => $vendorDir . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Util.php',
|
286 |
+
'PixelCaffeine\\Dependencies\\TypeError' => $vendorDir . '/paragonie/random_compat/lib/error_polyfill.php',
|
287 |
+
'PixelCaffeine\\FB\\ConnectorAdapter' => $baseDir . '/../includes/sdk/ConnectorAdapter.php',
|
288 |
+
'PixelCaffeine\\FB\\User_Data_Factory' => $baseDir . '/../includes/sdk/class-user-data-factory.php',
|
289 |
+
'PixelCaffeine\\Interfaces\\ECommerceAddOnInterface' => $baseDir . '/../includes/interfaces/interface-ecommerce-addon.php',
|
290 |
+
'PixelCaffeine\\Job\\RefreshAudiencesSize' => $baseDir . '/../includes/jobs/class-refresh-audiences-size.php',
|
291 |
+
'PixelCaffeine\\Logs\\Entity\\Log' => $baseDir . '/../includes/admin/logs/entity/class-log.php',
|
292 |
+
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => $baseDir . '/../includes/admin/logs/exception/exception-log-not-existing.php',
|
293 |
+
'PixelCaffeine\\Logs\\LogRepository' => $baseDir . '/../includes/admin/logs/class-log-repository.php',
|
294 |
+
'PixelCaffeine\\Logs\\LogRepositoryInterface' => $baseDir . '/../includes/admin/logs/interface-log-repository.php',
|
295 |
+
'PixelCaffeine\\Model\\Job' => $baseDir . '/../includes/models/class-job.php',
|
296 |
+
'PixelCaffeine\\ProductCatalog\\Admin\\Metaboxes' => $baseDir . '/../includes/product-catalogs/admin/class-metaboxes.php',
|
297 |
+
'PixelCaffeine\\ProductCatalog\\BackgroundFeedSaver' => $baseDir . '/../includes/product-catalogs/class-background-feed-saver.php',
|
298 |
+
'PixelCaffeine\\ProductCatalog\\BackgroundFeedSaverProcess' => $baseDir . '/../includes/product-catalogs/class-background-feed-saver-process.php',
|
299 |
+
'PixelCaffeine\\ProductCatalog\\Configuration' => $baseDir . '/../includes/product-catalogs/class-configuration.php',
|
300 |
+
'PixelCaffeine\\ProductCatalog\\ConfigurationDefaults' => $baseDir . '/../includes/product-catalogs/class-configuration-defaults.php',
|
301 |
+
'PixelCaffeine\\ProductCatalog\\Cron\\RefreshFeed' => $baseDir . '/../includes/product-catalogs/cron/class-refresh-feed.php',
|
302 |
+
'PixelCaffeine\\ProductCatalog\\DbProvider' => $baseDir . '/../includes/product-catalogs/class-db-provider.php',
|
303 |
+
'PixelCaffeine\\ProductCatalog\\Dictionary\\FeedSaver' => $baseDir . '/../includes/product-catalogs/dictionary/class-feed-saver.php',
|
304 |
+
'PixelCaffeine\\ProductCatalog\\Entity\\ProductCatalog' => $baseDir . '/../includes/product-catalogs/entity/class-product-catalog.php',
|
305 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\EntityException' => $baseDir . '/../includes/product-catalogs/exception/exception-entity.php',
|
306 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\FeedException' => $baseDir . '/../includes/product-catalogs/exception/exception-feed.php',
|
307 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\GoogleTaxonomyException' => $baseDir . '/../includes/product-catalogs/exception/exception-google-taxonomy.php',
|
308 |
+
'PixelCaffeine\\ProductCatalog\\FeedMapper' => $baseDir . '/../includes/product-catalogs/class-feed-mapper.php',
|
309 |
+
'PixelCaffeine\\ProductCatalog\\FeedSaverInterface' => $baseDir . '/../includes/product-catalogs/interface-feed-saver.php',
|
310 |
+
'PixelCaffeine\\ProductCatalog\\Feed\\WriterInterface' => $baseDir . '/../includes/product-catalogs/feed/interface-writer.php',
|
311 |
+
'PixelCaffeine\\ProductCatalog\\Feed\\XMLWriter' => $baseDir . '/../includes/product-catalogs/feed/class-xml-writer.php',
|
312 |
+
'PixelCaffeine\\ProductCatalog\\ForegroundFeedSaver' => $baseDir . '/../includes/product-catalogs/class-foreground-feed-saver.php',
|
313 |
+
'PixelCaffeine\\ProductCatalog\\Helper\\FeedDirectoryHelper' => $baseDir . '/../includes/product-catalogs/helper/class-feed-directory-helper.php',
|
314 |
+
'PixelCaffeine\\ProductCatalog\\ProductCatalogManager' => $baseDir . '/../includes/product-catalogs/class-product-catalog-manager.php',
|
315 |
+
'PixelCaffeine\\ProductCatalog\\ProductCatalogs' => $baseDir . '/../includes/product-catalogs/class-product-catalogs.php',
|
316 |
+
'PixelCaffeine\\ServerSide\\Conversions_API' => $baseDir . '/../includes/server-side/class-conversions-api.php',
|
317 |
+
'PixelCaffeine\\ServerSide\\Event_Factory' => $baseDir . '/../includes/server-side/class-event-factory.php',
|
318 |
+
'PixelCaffeine\\ServerSide\\Pixel_Event' => $baseDir . '/../includes/server-side/class-pixel-event.php',
|
319 |
+
'PixelCaffeine\\ServerSide\\Server_Side_Tracking' => $baseDir . '/../includes/server-side/class-server-side-tracking.php',
|
320 |
+
'WP_Async_Request' => $vendorDir . '/a5hleyrich/wp-background-processing/classes/wp-async-request.php',
|
321 |
+
'WP_Background_Process' => $vendorDir . '/a5hleyrich/wp-background-processing/classes/wp-background-process.php',
|
322 |
+
);
|
{vendor → third-party/vendor}/composer/autoload_namespaces.php
RENAMED
File without changes
|
third-party/vendor/composer/autoload_psr4.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_psr4.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
);
|
third-party/vendor/composer/autoload_real.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real.php @generated by Composer
|
4 |
+
|
5 |
+
class ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144
|
6 |
+
{
|
7 |
+
private static $loader;
|
8 |
+
|
9 |
+
public static function loadClassLoader($class)
|
10 |
+
{
|
11 |
+
if ('Composer\Autoload\ClassLoader' === $class) {
|
12 |
+
require __DIR__ . '/ClassLoader.php';
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return \Composer\Autoload\ClassLoader
|
18 |
+
*/
|
19 |
+
public static function getLoader()
|
20 |
+
{
|
21 |
+
if (null !== self::$loader) {
|
22 |
+
return self::$loader;
|
23 |
+
}
|
24 |
+
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144', 'loadClassLoader'), true, true);
|
26 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144', 'loadClassLoader'));
|
28 |
+
|
29 |
+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
+
if ($useStaticLoader) {
|
31 |
+
require_once __DIR__ . '/autoload_static.php';
|
32 |
+
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit2794c148e8d4f809de17342ff307f144::getInitializer($loader));
|
34 |
+
} else {
|
35 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
36 |
+
if ($classMap) {
|
37 |
+
$loader->addClassMap($classMap);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
$loader->setClassMapAuthoritative(true);
|
42 |
+
$loader->register(true);
|
43 |
+
|
44 |
+
return $loader;
|
45 |
+
}
|
46 |
+
}
|
third-party/vendor/composer/autoload_static.php
ADDED
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_static.php @generated by Composer
|
4 |
+
|
5 |
+
namespace Composer\Autoload;
|
6 |
+
|
7 |
+
class ComposerStaticInit2794c148e8d4f809de17342ff307f144
|
8 |
+
{
|
9 |
+
public static $classMap = array (
|
10 |
+
'AEPC_Addon_Factory' => __DIR__ . '/../..' . '/../includes/class-aepc-addon-factory.php',
|
11 |
+
'AEPC_Addon_Product_Item' => __DIR__ . '/../..' . '/../includes/class-aepc-addon-product-item.php',
|
12 |
+
'AEPC_Addons_Support' => __DIR__ . '/../..' . '/../includes/class-aepc-addons-support.php',
|
13 |
+
'AEPC_Admin' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin.php',
|
14 |
+
'AEPC_Admin_Ajax' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-ajax.php',
|
15 |
+
'AEPC_Admin_CA' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-ca.php',
|
16 |
+
'AEPC_Admin_CA_Manager' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-ca-manager.php',
|
17 |
+
'AEPC_Admin_Handlers' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-handlers.php',
|
18 |
+
'AEPC_Admin_Install' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-install.php',
|
19 |
+
'AEPC_Admin_Logger' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-logger.php',
|
20 |
+
'AEPC_Admin_Menu' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-menu.php',
|
21 |
+
'AEPC_Admin_Notices' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-notices.php',
|
22 |
+
'AEPC_Admin_Response' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-response.php',
|
23 |
+
'AEPC_Admin_View' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-admin-view.php',
|
24 |
+
'AEPC_Cron' => __DIR__ . '/../..' . '/../includes/class-aepc-cron.php',
|
25 |
+
'AEPC_Currency' => __DIR__ . '/../..' . '/../includes/class-aepc-currency.php',
|
26 |
+
'AEPC_Edd_Addon_Support' => __DIR__ . '/../..' . '/../includes/supports/class-aepc-edd-addon-support.php',
|
27 |
+
'AEPC_Facebook_Adapter' => __DIR__ . '/../..' . '/../includes/admin/class-aepc-facebook-adapter.php',
|
28 |
+
'AEPC_Pixel_Scripts' => __DIR__ . '/../..' . '/../includes/class-aepc-pixel-scripts.php',
|
29 |
+
'AEPC_Third_Party_Fixes' => __DIR__ . '/../..' . '/../includes/aepc-third-party-fixes.php',
|
30 |
+
'AEPC_Track' => __DIR__ . '/../..' . '/../includes/class-aepc-track.php',
|
31 |
+
'AEPC_Woocommerce_Addon_Support' => __DIR__ . '/../..' . '/../includes/supports/class-aepc-woocommerce-addon-support.php',
|
32 |
+
'PixelCaffeine\\Admin\\Exception\\AEPCException' => __DIR__ . '/../..' . '/../includes/admin/exceptions/exception-aepc-exception.php',
|
33 |
+
'PixelCaffeine\\Admin\\Exception\\FBAPIException' => __DIR__ . '/../..' . '/../includes/admin/exceptions/exception-fbapi.php',
|
34 |
+
'PixelCaffeine\\Admin\\Exception\\FBAPILoginException' => __DIR__ . '/../..' . '/../includes/admin/exceptions/exception-fbapi-login.php',
|
35 |
+
'PixelCaffeine\\Dependencies\\ArithmeticError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php',
|
36 |
+
'PixelCaffeine\\Dependencies\\AssertionError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php',
|
37 |
+
'PixelCaffeine\\Dependencies\\ComposerAutoloaderInit2794c148e8d4f809de17342ff307f144' => __DIR__ . '/..' . '/composer/autoload_real.php',
|
38 |
+
'PixelCaffeine\\Dependencies\\Composer\\Autoload\\ClassLoader' => __DIR__ . '/..' . '/composer/ClassLoader.php',
|
39 |
+
'PixelCaffeine\\Dependencies\\Composer\\Autoload\\ComposerStaticInit2794c148e8d4f809de17342ff307f144' => __DIR__ . '/..' . '/composer/autoload_static.php',
|
40 |
+
'PixelCaffeine\\Dependencies\\DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php',
|
41 |
+
'PixelCaffeine\\Dependencies\\Error' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php',
|
42 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\AnonymousSession' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/AnonymousSession.php',
|
43 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Api' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Api.php',
|
44 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\ApiConfig' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/ApiConfig.php',
|
45 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\ApiRequest' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/ApiRequest.php',
|
46 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\CrashReasons' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php',
|
47 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\CrashReporter' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php',
|
48 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Cursor' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Cursor.php',
|
49 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\AbstractEnum' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Enum/AbstractEnum.php',
|
50 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\EmptyEnum' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Enum/EmptyEnum.php',
|
51 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Enum\\EnumInstanceInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Enum/EnumInstanceInterface.php',
|
52 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Exception\\Exception' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Exception/Exception.php',
|
53 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\AbstractAdapter' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AbstractAdapter.php',
|
54 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\AdapterInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AdapterInterface.php',
|
55 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\CurlAdapter' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/CurlAdapter.php',
|
56 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\AbstractCurl' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/AbstractCurl.php',
|
57 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\Curl' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl.php',
|
58 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\Curl55' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl55.php',
|
59 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Adapter\\Curl\\CurlInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/CurlInterface.php',
|
60 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Client' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Client.php',
|
61 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\AuthorizationException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/AuthorizationException.php',
|
62 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ClientException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ClientException.php',
|
63 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\EmptyResponseException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/EmptyResponseException.php',
|
64 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\PermissionException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/PermissionException.php',
|
65 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\RequestException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php',
|
66 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ServerException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ServerException.php',
|
67 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Exception\\ThrottleException' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ThrottleException.php',
|
68 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\FileParameter' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/FileParameter.php',
|
69 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Headers' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Headers.php',
|
70 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Parameters' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Parameters.php',
|
71 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Request' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Request.php',
|
72 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\RequestInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/RequestInterface.php',
|
73 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Response' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Response.php',
|
74 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\ResponseInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/ResponseInterface.php',
|
75 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\SimpleRequest' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/SimpleRequest.php',
|
76 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Http\\Util' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Http/Util.php',
|
77 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger.php',
|
78 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger\\JsonAwareParameters' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonAwareParameters.php',
|
79 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\CurlLogger\\JsonNode' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonNode.php',
|
80 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\LoggerInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Logger/LoggerInterface.php',
|
81 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Logger\\NullLogger' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Logger/NullLogger.php',
|
82 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractArchivableCrudObject' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractArchivableCrudObject.php',
|
83 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractCrudObject' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractCrudObject.php',
|
84 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AbstractObject' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AbstractObject.php',
|
85 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixel' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixel.php',
|
86 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixelStats' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStats.php',
|
87 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\AdsPixelStatsResult' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStatsResult.php',
|
88 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AbstractArchivableCrudObjectFields' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AbstractArchivableCrudObjectFields.php',
|
89 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelFields' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelFields.php',
|
90 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelStatsFields' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsFields.php',
|
91 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Fields\\AdsPixelStatsResultFields' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsResultFields.php',
|
92 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\ActionSource' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/ActionSource.php',
|
93 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\AdsPixelSettings' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php',
|
94 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\AsyncClient' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AsyncClient.php',
|
95 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\BatchProcessor' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/BatchProcessor.php',
|
96 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Content' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Content.php',
|
97 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\CustomData' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/CustomData.php',
|
98 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\DeliveryCategory' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/DeliveryCategory.php',
|
99 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Event' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Event.php',
|
100 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventRequest' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php',
|
101 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventRequestAsync' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequestAsync.php',
|
102 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\EventResponse' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventResponse.php',
|
103 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Gender' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Gender.php',
|
104 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpMethod' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpMethod.php',
|
105 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpServiceClientConfig' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceClientConfig.php',
|
106 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\HttpServiceInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceInterface.php',
|
107 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Normalizer' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php',
|
108 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Singleton' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php',
|
109 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\UserData' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/UserData.php',
|
110 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\Util' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Util.php',
|
111 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelAutomaticMatchingFieldsValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelAutomaticMatchingFieldsValues.php',
|
112 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelDataUseSettingValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelDataUseSettingValues.php',
|
113 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelFirstPartyCookieStatusValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelFirstPartyCookieStatusValues.php',
|
114 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelSortByValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelSortByValues.php',
|
115 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelStatsResultAggregationValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelStatsResultAggregationValues.php',
|
116 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\Values\\AdsPixelTasksValues' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelTasksValues.php',
|
117 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\Session' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/Session.php',
|
118 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\SessionInterface' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/SessionInterface.php',
|
119 |
+
'PixelCaffeine\\Dependencies\\FacebookAds\\TypeChecker' => __DIR__ . '/..' . '/facebook/php-business-sdk/src/FacebookAds/TypeChecker.php',
|
120 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\BeforeValidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/BeforeValidException.php',
|
121 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\ExpiredException' => __DIR__ . '/..' . '/firebase/php-jwt/src/ExpiredException.php',
|
122 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\JWT' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWT.php',
|
123 |
+
'PixelCaffeine\\Dependencies\\Firebase\\JWT\\SignatureInvalidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/SignatureInvalidException.php',
|
124 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Client' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Client.php',
|
125 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\ClientInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ClientInterface.php',
|
126 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\CookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
|
127 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\CookieJarInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
|
128 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\FileCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
|
129 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\SessionCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
|
130 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Cookie\\SetCookie' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
|
131 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\BadResponseException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
|
132 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ClientException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
|
133 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ConnectException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
|
134 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\GuzzleException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/GuzzleException.php',
|
135 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\InvalidArgumentException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php',
|
136 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\RequestException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
|
137 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\SeekException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/SeekException.php',
|
138 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\ServerException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
|
139 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\TooManyRedirectsException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
|
140 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Exception\\TransferException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
|
141 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\HandlerStack' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/HandlerStack.php',
|
142 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlFactory' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlFactory.php',
|
143 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlFactoryInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php',
|
144 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlHandler.php',
|
145 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\CurlMultiHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php',
|
146 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\EasyHandle' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/EasyHandle.php',
|
147 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\MockHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/MockHandler.php',
|
148 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\Proxy' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/Proxy.php',
|
149 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Handler\\StreamHandler' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Handler/StreamHandler.php',
|
150 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\MessageFormatter' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/MessageFormatter.php',
|
151 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Middleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Middleware.php',
|
152 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Pool' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Pool.php',
|
153 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\PrepareBodyMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php',
|
154 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\AggregateException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/AggregateException.php',
|
155 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\CancellationException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/CancellationException.php',
|
156 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Coroutine' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Coroutine.php',
|
157 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Create' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Create.php',
|
158 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Each' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Each.php',
|
159 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\EachPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/EachPromise.php',
|
160 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\FulfilledPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/FulfilledPromise.php',
|
161 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Is' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Is.php',
|
162 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Promise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Promise.php',
|
163 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\PromiseInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/PromiseInterface.php',
|
164 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\PromisorInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/PromisorInterface.php',
|
165 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\RejectedPromise' => __DIR__ . '/..' . '/guzzlehttp/promises/src/RejectedPromise.php',
|
166 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\RejectionException' => __DIR__ . '/..' . '/guzzlehttp/promises/src/RejectionException.php',
|
167 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\TaskQueue' => __DIR__ . '/..' . '/guzzlehttp/promises/src/TaskQueue.php',
|
168 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\TaskQueueInterface' => __DIR__ . '/..' . '/guzzlehttp/promises/src/TaskQueueInterface.php',
|
169 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\Utils' => __DIR__ . '/..' . '/guzzlehttp/promises/src/Utils.php',
|
170 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\AppendStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/AppendStream.php',
|
171 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\BufferStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/BufferStream.php',
|
172 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\CachingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/CachingStream.php',
|
173 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/DroppingStream.php',
|
174 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/FnStream.php',
|
175 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Header' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Header.php',
|
176 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/InflateStream.php',
|
177 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LazyOpenStream.php',
|
178 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LimitStream.php',
|
179 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Message' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Message.php',
|
180 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MessageTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MessageTrait.php',
|
181 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MimeType' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MimeType.php',
|
182 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\MultipartStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MultipartStream.php',
|
183 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\NoSeekStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/NoSeekStream.php',
|
184 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\PumpStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/PumpStream.php',
|
185 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Query' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Query.php',
|
186 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Request' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Request.php',
|
187 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Response' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Response.php',
|
188 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Rfc7230' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Rfc7230.php',
|
189 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\ServerRequest' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/ServerRequest.php',
|
190 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Stream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Stream.php',
|
191 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\StreamDecoratorTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php',
|
192 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\StreamWrapper' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamWrapper.php',
|
193 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UploadedFile' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UploadedFile.php',
|
194 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Uri' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Uri.php',
|
195 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UriNormalizer' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriNormalizer.php',
|
196 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\UriResolver' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriResolver.php',
|
197 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\Utils' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Utils.php',
|
198 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RedirectMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RedirectMiddleware.php',
|
199 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RequestOptions' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RequestOptions.php',
|
200 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\RetryMiddleware' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RetryMiddleware.php',
|
201 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\TransferStats' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/TransferStats.php',
|
202 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\UriTemplate' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/UriTemplate.php',
|
203 |
+
'PixelCaffeine\\Dependencies\\GuzzleHttp\\Utils' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Utils.php',
|
204 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\DownloadsParser' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/DownloadsParser.php',
|
205 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\GlobCleaner' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/GlobCleaner.php',
|
206 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\ArchiveHandler' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Handler/ArchiveHandler.php',
|
207 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\BaseHandler' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Handler/BaseHandler.php',
|
208 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\FileHandler' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Handler/FileHandler.php',
|
209 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Handler\\PharHandler' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Handler/PharHandler.php',
|
210 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Plugin' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Plugin.php',
|
211 |
+
'PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\Subpackage' => __DIR__ . '/..' . '/civicrm/composer-downloads-plugin/src/Subpackage.php',
|
212 |
+
'PixelCaffeine\\Dependencies\\Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
213 |
+
'PixelCaffeine\\Dependencies\\ParseError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ParseError.php',
|
214 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\MessageInterface' => __DIR__ . '/..' . '/psr/http-message/src/MessageInterface.php',
|
215 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\RequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/RequestInterface.php',
|
216 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\ResponseInterface' => __DIR__ . '/..' . '/psr/http-message/src/ResponseInterface.php',
|
217 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\ServerRequestInterface' => __DIR__ . '/..' . '/psr/http-message/src/ServerRequestInterface.php',
|
218 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\StreamInterface' => __DIR__ . '/..' . '/psr/http-message/src/StreamInterface.php',
|
219 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\UploadedFileInterface' => __DIR__ . '/..' . '/psr/http-message/src/UploadedFileInterface.php',
|
220 |
+
'PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\UriInterface' => __DIR__ . '/..' . '/psr/http-message/src/UriInterface.php',
|
221 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\BinaryUtils' => __DIR__ . '/..' . '/ramsey/uuid/src/BinaryUtils.php',
|
222 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php',
|
223 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php',
|
224 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Builder\\UuidBuilderInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/UuidBuilderInterface.php',
|
225 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\CodecInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/CodecInterface.php',
|
226 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\GuidStringCodec' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/GuidStringCodec.php',
|
227 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\OrderedTimeCodec' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/OrderedTimeCodec.php',
|
228 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\StringCodec' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/StringCodec.php',
|
229 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\TimestampFirstCombCodec' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php',
|
230 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Codec\\TimestampLastCombCodec' => __DIR__ . '/..' . '/ramsey/uuid/src/Codec/TimestampLastCombCodec.php',
|
231 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\NumberConverterInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/NumberConverterInterface.php',
|
232 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Number\\BigNumberConverter' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/Number/BigNumberConverter.php',
|
233 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Number\\DegradedNumberConverter' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php',
|
234 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\TimeConverterInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/TimeConverterInterface.php',
|
235 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\BigNumberTimeConverter' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php',
|
236 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\DegradedTimeConverter' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php',
|
237 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Converter\\Time\\PhpTimeConverter' => __DIR__ . '/..' . '/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php',
|
238 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\DegradedUuid' => __DIR__ . '/..' . '/ramsey/uuid/src/DegradedUuid.php',
|
239 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\InvalidUuidStringException' => __DIR__ . '/..' . '/ramsey/uuid/src/Exception/InvalidUuidStringException.php',
|
240 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\UnsatisfiedDependencyException' => __DIR__ . '/..' . '/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php',
|
241 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Exception\\UnsupportedOperationException' => __DIR__ . '/..' . '/ramsey/uuid/src/Exception/UnsupportedOperationException.php',
|
242 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\FeatureSet' => __DIR__ . '/..' . '/ramsey/uuid/src/FeatureSet.php',
|
243 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\CombGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/CombGenerator.php',
|
244 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\DefaultTimeGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/DefaultTimeGenerator.php',
|
245 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\MtRandGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/MtRandGenerator.php',
|
246 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\OpenSslGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/OpenSslGenerator.php',
|
247 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\PeclUuidRandomGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php',
|
248 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\PeclUuidTimeGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php',
|
249 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomBytesGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/RandomBytesGenerator.php',
|
250 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomGeneratorFactory' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/RandomGeneratorFactory.php',
|
251 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomGeneratorInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/RandomGeneratorInterface.php',
|
252 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\RandomLibAdapter' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/RandomLibAdapter.php',
|
253 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\SodiumRandomGenerator' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/SodiumRandomGenerator.php',
|
254 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\TimeGeneratorFactory' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/TimeGeneratorFactory.php',
|
255 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Generator\\TimeGeneratorInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Generator/TimeGeneratorInterface.php',
|
256 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\NodeProviderInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/NodeProviderInterface.php',
|
257 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\FallbackNodeProvider' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php',
|
258 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\RandomNodeProvider' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php',
|
259 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Node\\SystemNodeProvider' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php',
|
260 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\TimeProviderInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/TimeProviderInterface.php',
|
261 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Time\\FixedTimeProvider' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php',
|
262 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Provider\\Time\\SystemTimeProvider' => __DIR__ . '/..' . '/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php',
|
263 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\Uuid' => __DIR__ . '/..' . '/ramsey/uuid/src/Uuid.php',
|
264 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidFactory' => __DIR__ . '/..' . '/ramsey/uuid/src/UuidFactory.php',
|
265 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidFactoryInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/UuidFactoryInterface.php',
|
266 |
+
'PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\UuidInterface' => __DIR__ . '/..' . '/ramsey/uuid/src/UuidInterface.php',
|
267 |
+
'PixelCaffeine\\Dependencies\\SessionUpdateTimestampHandlerInterface' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php',
|
268 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/filesystem/Exception/ExceptionInterface.php',
|
269 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\FileNotFoundException' => __DIR__ . '/..' . '/symfony/filesystem/Exception/FileNotFoundException.php',
|
270 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\IOException' => __DIR__ . '/..' . '/symfony/filesystem/Exception/IOException.php',
|
271 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Exception\\IOExceptionInterface' => __DIR__ . '/..' . '/symfony/filesystem/Exception/IOExceptionInterface.php',
|
272 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\Filesystem' => __DIR__ . '/..' . '/symfony/filesystem/Filesystem.php',
|
273 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\LockHandler' => __DIR__ . '/..' . '/symfony/filesystem/LockHandler.php',
|
274 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
|
275 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Idn' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/Idn.php',
|
276 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Info' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/Info.php',
|
277 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Resources\\unidata\\DisallowedRanges' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/Resources/unidata/DisallowedRanges.php',
|
278 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\Resources\\unidata\\Regex' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/Resources/unidata/Regex.php',
|
279 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Normalizer\\Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Normalizer.php',
|
280 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php70\\Php70' => __DIR__ . '/..' . '/symfony/polyfill-php70/Php70.php',
|
281 |
+
'PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php72\\Php72' => __DIR__ . '/..' . '/symfony/polyfill-php72/Php72.php',
|
282 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_FileFinder' => __DIR__ . '/..' . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/FileFinder.php',
|
283 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Pattern' => __DIR__ . '/..' . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Pattern.php',
|
284 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Rule' => __DIR__ . '/..' . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Rule.php',
|
285 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Ruleset' => __DIR__ . '/..' . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Ruleset.php',
|
286 |
+
'PixelCaffeine\\Dependencies\\TOGoS_GitIgnore_Util' => __DIR__ . '/..' . '/togos/gitignore/src/main/php/TOGoS/GitIgnore/Util.php',
|
287 |
+
'PixelCaffeine\\Dependencies\\TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php',
|
288 |
+
'PixelCaffeine\\FB\\ConnectorAdapter' => __DIR__ . '/../..' . '/../includes/sdk/ConnectorAdapter.php',
|
289 |
+
'PixelCaffeine\\FB\\User_Data_Factory' => __DIR__ . '/../..' . '/../includes/sdk/class-user-data-factory.php',
|
290 |
+
'PixelCaffeine\\Interfaces\\ECommerceAddOnInterface' => __DIR__ . '/../..' . '/../includes/interfaces/interface-ecommerce-addon.php',
|
291 |
+
'PixelCaffeine\\Job\\RefreshAudiencesSize' => __DIR__ . '/../..' . '/../includes/jobs/class-refresh-audiences-size.php',
|
292 |
+
'PixelCaffeine\\Logs\\Entity\\Log' => __DIR__ . '/../..' . '/../includes/admin/logs/entity/class-log.php',
|
293 |
+
'PixelCaffeine\\Logs\\Exception\\LogNotExistingException' => __DIR__ . '/../..' . '/../includes/admin/logs/exception/exception-log-not-existing.php',
|
294 |
+
'PixelCaffeine\\Logs\\LogRepository' => __DIR__ . '/../..' . '/../includes/admin/logs/class-log-repository.php',
|
295 |
+
'PixelCaffeine\\Logs\\LogRepositoryInterface' => __DIR__ . '/../..' . '/../includes/admin/logs/interface-log-repository.php',
|
296 |
+
'PixelCaffeine\\Model\\Job' => __DIR__ . '/../..' . '/../includes/models/class-job.php',
|
297 |
+
'PixelCaffeine\\ProductCatalog\\Admin\\Metaboxes' => __DIR__ . '/../..' . '/../includes/product-catalogs/admin/class-metaboxes.php',
|
298 |
+
'PixelCaffeine\\ProductCatalog\\BackgroundFeedSaver' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-background-feed-saver.php',
|
299 |
+
'PixelCaffeine\\ProductCatalog\\BackgroundFeedSaverProcess' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-background-feed-saver-process.php',
|
300 |
+
'PixelCaffeine\\ProductCatalog\\Configuration' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-configuration.php',
|
301 |
+
'PixelCaffeine\\ProductCatalog\\ConfigurationDefaults' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-configuration-defaults.php',
|
302 |
+
'PixelCaffeine\\ProductCatalog\\Cron\\RefreshFeed' => __DIR__ . '/../..' . '/../includes/product-catalogs/cron/class-refresh-feed.php',
|
303 |
+
'PixelCaffeine\\ProductCatalog\\DbProvider' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-db-provider.php',
|
304 |
+
'PixelCaffeine\\ProductCatalog\\Dictionary\\FeedSaver' => __DIR__ . '/../..' . '/../includes/product-catalogs/dictionary/class-feed-saver.php',
|
305 |
+
'PixelCaffeine\\ProductCatalog\\Entity\\ProductCatalog' => __DIR__ . '/../..' . '/../includes/product-catalogs/entity/class-product-catalog.php',
|
306 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\EntityException' => __DIR__ . '/../..' . '/../includes/product-catalogs/exception/exception-entity.php',
|
307 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\FeedException' => __DIR__ . '/../..' . '/../includes/product-catalogs/exception/exception-feed.php',
|
308 |
+
'PixelCaffeine\\ProductCatalog\\Exception\\GoogleTaxonomyException' => __DIR__ . '/../..' . '/../includes/product-catalogs/exception/exception-google-taxonomy.php',
|
309 |
+
'PixelCaffeine\\ProductCatalog\\FeedMapper' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-feed-mapper.php',
|
310 |
+
'PixelCaffeine\\ProductCatalog\\FeedSaverInterface' => __DIR__ . '/../..' . '/../includes/product-catalogs/interface-feed-saver.php',
|
311 |
+
'PixelCaffeine\\ProductCatalog\\Feed\\WriterInterface' => __DIR__ . '/../..' . '/../includes/product-catalogs/feed/interface-writer.php',
|
312 |
+
'PixelCaffeine\\ProductCatalog\\Feed\\XMLWriter' => __DIR__ . '/../..' . '/../includes/product-catalogs/feed/class-xml-writer.php',
|
313 |
+
'PixelCaffeine\\ProductCatalog\\ForegroundFeedSaver' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-foreground-feed-saver.php',
|
314 |
+
'PixelCaffeine\\ProductCatalog\\Helper\\FeedDirectoryHelper' => __DIR__ . '/../..' . '/../includes/product-catalogs/helper/class-feed-directory-helper.php',
|
315 |
+
'PixelCaffeine\\ProductCatalog\\ProductCatalogManager' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-product-catalog-manager.php',
|
316 |
+
'PixelCaffeine\\ProductCatalog\\ProductCatalogs' => __DIR__ . '/../..' . '/../includes/product-catalogs/class-product-catalogs.php',
|
317 |
+
'PixelCaffeine\\ServerSide\\Conversions_API' => __DIR__ . '/../..' . '/../includes/server-side/class-conversions-api.php',
|
318 |
+
'PixelCaffeine\\ServerSide\\Event_Factory' => __DIR__ . '/../..' . '/../includes/server-side/class-event-factory.php',
|
319 |
+
'PixelCaffeine\\ServerSide\\Pixel_Event' => __DIR__ . '/../..' . '/../includes/server-side/class-pixel-event.php',
|
320 |
+
'PixelCaffeine\\ServerSide\\Server_Side_Tracking' => __DIR__ . '/../..' . '/../includes/server-side/class-server-side-tracking.php',
|
321 |
+
'WP_Async_Request' => __DIR__ . '/..' . '/a5hleyrich/wp-background-processing/classes/wp-async-request.php',
|
322 |
+
'WP_Background_Process' => __DIR__ . '/..' . '/a5hleyrich/wp-background-processing/classes/wp-background-process.php',
|
323 |
+
);
|
324 |
+
|
325 |
+
public static function getInitializer(ClassLoader $loader)
|
326 |
+
{
|
327 |
+
return \Closure::bind(function () use ($loader) {
|
328 |
+
$loader->classMap = ComposerStaticInit2794c148e8d4f809de17342ff307f144::$classMap;
|
329 |
+
|
330 |
+
}, null, ClassLoader::class);
|
331 |
+
}
|
332 |
+
}
|
third-party/vendor/composer/installed.json
ADDED
@@ -0,0 +1,1088 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"name": "a5hleyrich\/wp-background-processing",
|
4 |
+
"version": "1.0.2",
|
5 |
+
"version_normalized": "1.0.2.0",
|
6 |
+
"source": {
|
7 |
+
"type": "git",
|
8 |
+
"url": "https:\/\/github.com\/deliciousbrains\/wp-background-processing.git",
|
9 |
+
"reference": "2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800"
|
10 |
+
},
|
11 |
+
"dist": {
|
12 |
+
"type": "zip",
|
13 |
+
"url": "https:\/\/api.github.com\/repos\/deliciousbrains\/wp-background-processing\/zipball\/2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800",
|
14 |
+
"reference": "2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800",
|
15 |
+
"shasum": ""
|
16 |
+
},
|
17 |
+
"require": {
|
18 |
+
"php": ">=5.2"
|
19 |
+
},
|
20 |
+
"suggest": {
|
21 |
+
"coenjacobs\/mozart": "Easily wrap this library with your own prefix, to prevent collisions when multiple plugins use this library"
|
22 |
+
},
|
23 |
+
"time": "2020-07-31T07:00:11+00:00",
|
24 |
+
"type": "library",
|
25 |
+
"installation-source": "dist",
|
26 |
+
"autoload": {
|
27 |
+
"classmap": [
|
28 |
+
"classes\/"
|
29 |
+
]
|
30 |
+
},
|
31 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
32 |
+
"license": [
|
33 |
+
"GPL-2.0-or-later"
|
34 |
+
],
|
35 |
+
"authors": [
|
36 |
+
{
|
37 |
+
"name": "Delicious Brains",
|
38 |
+
"email": "nom@deliciousbrains.com"
|
39 |
+
}
|
40 |
+
],
|
41 |
+
"description": "WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks."
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"name": "civicrm\/composer-downloads-plugin",
|
45 |
+
"version": "v3.0.1",
|
46 |
+
"version_normalized": "3.0.1.0",
|
47 |
+
"source": {
|
48 |
+
"type": "git",
|
49 |
+
"url": "https:\/\/github.com\/civicrm\/composer-downloads-plugin.git",
|
50 |
+
"reference": "3aabb6d259a86158d01829fc2c62a2afb9618877"
|
51 |
+
},
|
52 |
+
"dist": {
|
53 |
+
"type": "zip",
|
54 |
+
"url": "https:\/\/api.github.com\/repos\/civicrm\/composer-downloads-plugin\/zipball\/3aabb6d259a86158d01829fc2c62a2afb9618877",
|
55 |
+
"reference": "3aabb6d259a86158d01829fc2c62a2afb9618877",
|
56 |
+
"shasum": ""
|
57 |
+
},
|
58 |
+
"require": {
|
59 |
+
"composer-plugin-api": "^1.1 || ^2.0",
|
60 |
+
"php": ">=5.6",
|
61 |
+
"togos\/gitignore": "~1.1.1"
|
62 |
+
},
|
63 |
+
"require-dev": {
|
64 |
+
"composer\/composer": "~1.0 || ~2.0",
|
65 |
+
"friendsofphp\/php-cs-fixer": "^2.3",
|
66 |
+
"phpunit\/phpunit": "^5.7",
|
67 |
+
"totten\/process-helper": "^1.0.1"
|
68 |
+
},
|
69 |
+
"time": "2020-11-02T05:26:23+00:00",
|
70 |
+
"type": "composer-plugin",
|
71 |
+
"extra": {
|
72 |
+
"class": "LastCall\\DownloadsPlugin\\Plugin"
|
73 |
+
},
|
74 |
+
"installation-source": "dist",
|
75 |
+
"autoload": {
|
76 |
+
"psr-4": {
|
77 |
+
"PixelCaffeine\\Dependencies\\LastCall\\DownloadsPlugin\\": "src\/"
|
78 |
+
}
|
79 |
+
},
|
80 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
81 |
+
"license": [
|
82 |
+
"MIT"
|
83 |
+
],
|
84 |
+
"authors": [
|
85 |
+
{
|
86 |
+
"name": "Rob Bayliss",
|
87 |
+
"email": "rob@lastcallmedia.com"
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"name": "Tim Otten",
|
91 |
+
"email": "totten@civicrm.org"
|
92 |
+
}
|
93 |
+
],
|
94 |
+
"description": "Composer plugin for downloading additional files within any composer package."
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"name": "facebook\/php-business-sdk",
|
98 |
+
"version": "9.0.4",
|
99 |
+
"version_normalized": "9.0.4.0",
|
100 |
+
"source": {
|
101 |
+
"type": "git",
|
102 |
+
"url": "https:\/\/github.com\/facebook\/facebook-php-business-sdk.git",
|
103 |
+
"reference": "c29498ee7f180583cb16873e5047eeeada834067"
|
104 |
+
},
|
105 |
+
"dist": {
|
106 |
+
"type": "zip",
|
107 |
+
"url": "https:\/\/api.github.com\/repos\/facebook\/facebook-php-business-sdk\/zipball\/c29498ee7f180583cb16873e5047eeeada834067",
|
108 |
+
"reference": "c29498ee7f180583cb16873e5047eeeada834067",
|
109 |
+
"shasum": ""
|
110 |
+
},
|
111 |
+
"require": {
|
112 |
+
"guzzlehttp\/guzzle": "^6.5 || ^7.0"
|
113 |
+
},
|
114 |
+
"require-dev": {
|
115 |
+
"mockery\/mockery": "1.3.3",
|
116 |
+
"phpunit\/phpunit": "~8",
|
117 |
+
"symfony\/finder": "~2.6"
|
118 |
+
},
|
119 |
+
"time": "2021-02-16T22:35:02+00:00",
|
120 |
+
"type": "library",
|
121 |
+
"installation-source": "dist",
|
122 |
+
"autoload": {
|
123 |
+
"psr-4": {
|
124 |
+
"PixelCaffeine\\Dependencies\\FacebookAds\\": "src\/FacebookAds\/"
|
125 |
+
}
|
126 |
+
},
|
127 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
128 |
+
"description": "PHP SDK for Facebook Business",
|
129 |
+
"homepage": "https:\/\/developers.facebook.com\/",
|
130 |
+
"keywords": [
|
131 |
+
"ads",
|
132 |
+
"business",
|
133 |
+
"facebook",
|
134 |
+
"instagram",
|
135 |
+
"page",
|
136 |
+
"sdk"
|
137 |
+
]
|
138 |
+
},
|
139 |
+
{
|
140 |
+
"name": "firebase\/php-jwt",
|
141 |
+
"version": "v4.0.0",
|
142 |
+
"version_normalized": "4.0.0.0",
|
143 |
+
"source": {
|
144 |
+
"type": "git",
|
145 |
+
"url": "https:\/\/github.com\/firebase\/php-jwt.git",
|
146 |
+
"reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35"
|
147 |
+
},
|
148 |
+
"dist": {
|
149 |
+
"type": "zip",
|
150 |
+
"url": "https:\/\/api.github.com\/repos\/firebase\/php-jwt\/zipball\/dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
|
151 |
+
"reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
|
152 |
+
"shasum": ""
|
153 |
+
},
|
154 |
+
"require": {
|
155 |
+
"php": ">=5.3.0"
|
156 |
+
},
|
157 |
+
"time": "2016-07-18T04:51:16+00:00",
|
158 |
+
"type": "library",
|
159 |
+
"installation-source": "dist",
|
160 |
+
"autoload": {
|
161 |
+
"psr-4": {
|
162 |
+
"PixelCaffeine\\Dependencies\\Firebase\\JWT\\": "src"
|
163 |
+
}
|
164 |
+
},
|
165 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
166 |
+
"license": [
|
167 |
+
"BSD-3-Clause"
|
168 |
+
],
|
169 |
+
"authors": [
|
170 |
+
{
|
171 |
+
"name": "Neuman Vong",
|
172 |
+
"email": "neuman+pear@twilio.com",
|
173 |
+
"role": "Developer"
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"name": "Anant Narayanan",
|
177 |
+
"email": "anant@php.net",
|
178 |
+
"role": "Developer"
|
179 |
+
}
|
180 |
+
],
|
181 |
+
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
182 |
+
"homepage": "https:\/\/github.com\/firebase\/php-jwt"
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"name": "guzzlehttp\/guzzle",
|
186 |
+
"version": "6.5.5",
|
187 |
+
"version_normalized": "6.5.5.0",
|
188 |
+
"source": {
|
189 |
+
"type": "git",
|
190 |
+
"url": "https:\/\/github.com\/guzzle\/guzzle.git",
|
191 |
+
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e"
|
192 |
+
},
|
193 |
+
"dist": {
|
194 |
+
"type": "zip",
|
195 |
+
"url": "https:\/\/api.github.com\/repos\/guzzle\/guzzle\/zipball\/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
196 |
+
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
197 |
+
"shasum": ""
|
198 |
+
},
|
199 |
+
"require": {
|
200 |
+
"ext-json": "*",
|
201 |
+
"guzzlehttp\/promises": "^1.0",
|
202 |
+
"guzzlehttp\/psr7": "^1.6.1",
|
203 |
+
"php": ">=5.5",
|
204 |
+
"symfony\/polyfill-intl-idn": "^1.17.0"
|
205 |
+
},
|
206 |
+
"require-dev": {
|
207 |
+
"ext-curl": "*",
|
208 |
+
"phpunit\/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
209 |
+
"psr\/log": "^1.1"
|
210 |
+
},
|
211 |
+
"suggest": {
|
212 |
+
"psr\/log": "Required for using the Log middleware"
|
213 |
+
},
|
214 |
+
"time": "2020-06-16T21:01:06+00:00",
|
215 |
+
"type": "library",
|
216 |
+
"extra": {
|
217 |
+
"branch-alias": {
|
218 |
+
"dev-master": "6.5-dev"
|
219 |
+
}
|
220 |
+
},
|
221 |
+
"installation-source": "dist",
|
222 |
+
"autoload": {
|
223 |
+
"psr-4": {
|
224 |
+
"PixelCaffeine\\Dependencies\\GuzzleHttp\\": "src\/"
|
225 |
+
},
|
226 |
+
"files": [
|
227 |
+
"src\/functions_include.php"
|
228 |
+
]
|
229 |
+
},
|
230 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
231 |
+
"license": [
|
232 |
+
"MIT"
|
233 |
+
],
|
234 |
+
"authors": [
|
235 |
+
{
|
236 |
+
"name": "Michael Dowling",
|
237 |
+
"email": "mtdowling@gmail.com",
|
238 |
+
"homepage": "https:\/\/github.com\/mtdowling"
|
239 |
+
}
|
240 |
+
],
|
241 |
+
"description": "Guzzle is a PHP HTTP client library",
|
242 |
+
"homepage": "http:\/\/guzzlephp.org\/",
|
243 |
+
"keywords": [
|
244 |
+
"client",
|
245 |
+
"curl",
|
246 |
+
"framework",
|
247 |
+
"http",
|
248 |
+
"http client",
|
249 |
+
"rest",
|
250 |
+
"web service"
|
251 |
+
]
|
252 |
+
},
|
253 |
+
{
|
254 |
+
"name": "guzzlehttp\/promises",
|
255 |
+
"version": "1.4.0",
|
256 |
+
"version_normalized": "1.4.0.0",
|
257 |
+
"source": {
|
258 |
+
"type": "git",
|
259 |
+
"url": "https:\/\/github.com\/guzzle\/promises.git",
|
260 |
+
"reference": "60d379c243457e073cff02bc323a2a86cb355631"
|
261 |
+
},
|
262 |
+
"dist": {
|
263 |
+
"type": "zip",
|
264 |
+
"url": "https:\/\/api.github.com\/repos\/guzzle\/promises\/zipball\/60d379c243457e073cff02bc323a2a86cb355631",
|
265 |
+
"reference": "60d379c243457e073cff02bc323a2a86cb355631",
|
266 |
+
"shasum": ""
|
267 |
+
},
|
268 |
+
"require": {
|
269 |
+
"php": ">=5.5"
|
270 |
+
},
|
271 |
+
"require-dev": {
|
272 |
+
"symfony\/phpunit-bridge": "^4.4 || ^5.1"
|
273 |
+
},
|
274 |
+
"time": "2020-09-30T07:37:28+00:00",
|
275 |
+
"type": "library",
|
276 |
+
"extra": {
|
277 |
+
"branch-alias": {
|
278 |
+
"dev-master": "1.4-dev"
|
279 |
+
}
|
280 |
+
},
|
281 |
+
"installation-source": "dist",
|
282 |
+
"autoload": {
|
283 |
+
"psr-4": {
|
284 |
+
"PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\": "src\/"
|
285 |
+
},
|
286 |
+
"files": [
|
287 |
+
"src\/functions_include.php"
|
288 |
+
]
|
289 |
+
},
|
290 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
291 |
+
"license": [
|
292 |
+
"MIT"
|
293 |
+
],
|
294 |
+
"authors": [
|
295 |
+
{
|
296 |
+
"name": "Michael Dowling",
|
297 |
+
"email": "mtdowling@gmail.com",
|
298 |
+
"homepage": "https:\/\/github.com\/mtdowling"
|
299 |
+
}
|
300 |
+
],
|
301 |
+
"description": "Guzzle promises library",
|
302 |
+
"keywords": [
|
303 |
+
"promise"
|
304 |
+
]
|
305 |
+
},
|
306 |
+
{
|
307 |
+
"name": "guzzlehttp\/psr7",
|
308 |
+
"version": "1.7.0",
|
309 |
+
"version_normalized": "1.7.0.0",
|
310 |
+
"source": {
|
311 |
+
"type": "git",
|
312 |
+
"url": "https:\/\/github.com\/guzzle\/psr7.git",
|
313 |
+
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3"
|
314 |
+
},
|
315 |
+
"dist": {
|
316 |
+
"type": "zip",
|
317 |
+
"url": "https:\/\/api.github.com\/repos\/guzzle\/psr7\/zipball\/53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
318 |
+
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
319 |
+
"shasum": ""
|
320 |
+
},
|
321 |
+
"require": {
|
322 |
+
"php": ">=5.4.0",
|
323 |
+
"psr\/http-message": "~1.0",
|
324 |
+
"ralouphie\/getallheaders": "^2.0.5 || ^3.0.0"
|
325 |
+
},
|
326 |
+
"provide": {
|
327 |
+
"psr\/http-message-implementation": "1.0"
|
328 |
+
},
|
329 |
+
"require-dev": {
|
330 |
+
"ext-zlib": "*",
|
331 |
+
"phpunit\/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
|
332 |
+
},
|
333 |
+
"suggest": {
|
334 |
+
"laminas\/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
335 |
+
},
|
336 |
+
"time": "2020-09-30T07:37:11+00:00",
|
337 |
+
"type": "library",
|
338 |
+
"extra": {
|
339 |
+
"branch-alias": {
|
340 |
+
"dev-master": "1.7-dev"
|
341 |
+
}
|
342 |
+
},
|
343 |
+
"installation-source": "dist",
|
344 |
+
"autoload": {
|
345 |
+
"psr-4": {
|
346 |
+
"PixelCaffeine\\Dependencies\\GuzzleHttp\\Psr7\\": "src\/"
|
347 |
+
},
|
348 |
+
"files": [
|
349 |
+
"src\/functions_include.php"
|
350 |
+
]
|
351 |
+
},
|
352 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
353 |
+
"license": [
|
354 |
+
"MIT"
|
355 |
+
],
|
356 |
+
"authors": [
|
357 |
+
{
|
358 |
+
"name": "Michael Dowling",
|
359 |
+
"email": "mtdowling@gmail.com",
|
360 |
+
"homepage": "https:\/\/github.com\/mtdowling"
|
361 |
+
},
|
362 |
+
{
|
363 |
+
"name": "Tobias Schultze",
|
364 |
+
"homepage": "https:\/\/github.com\/Tobion"
|
365 |
+
}
|
366 |
+
],
|
367 |
+
"description": "PSR-7 message implementation that also provides common utility methods",
|
368 |
+
"keywords": [
|
369 |
+
"http",
|
370 |
+
"message",
|
371 |
+
"psr-7",
|
372 |
+
"request",
|
373 |
+
"response",
|
374 |
+
"stream",
|
375 |
+
"uri",
|
376 |
+
"url"
|
377 |
+
]
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"name": "paragonie\/random_compat",
|
381 |
+
"version": "v2.0.19",
|
382 |
+
"version_normalized": "2.0.19.0",
|
383 |
+
"source": {
|
384 |
+
"type": "git",
|
385 |
+
"url": "https:\/\/github.com\/paragonie\/random_compat.git",
|
386 |
+
"reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241"
|
387 |
+
},
|
388 |
+
"dist": {
|
389 |
+
"type": "zip",
|
390 |
+
"url": "https:\/\/api.github.com\/repos\/paragonie\/random_compat\/zipball\/446fc9faa5c2a9ddf65eb7121c0af7e857295241",
|
391 |
+
"reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241",
|
392 |
+
"shasum": ""
|
393 |
+
},
|
394 |
+
"require": {
|
395 |
+
"php": ">=5.2.0"
|
396 |
+
},
|
397 |
+
"require-dev": {
|
398 |
+
"phpunit\/phpunit": "4.*|5.*"
|
399 |
+
},
|
400 |
+
"suggest": {
|
401 |
+
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
402 |
+
},
|
403 |
+
"time": "2020-10-15T10:06:57+00:00",
|
404 |
+
"type": "library",
|
405 |
+
"installation-source": "dist",
|
406 |
+
"autoload": {
|
407 |
+
"files": [
|
408 |
+
"lib\/random.php"
|
409 |
+
]
|
410 |
+
},
|
411 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
412 |
+
"license": [
|
413 |
+
"MIT"
|
414 |
+
],
|
415 |
+
"authors": [
|
416 |
+
{
|
417 |
+
"name": "Paragon Initiative Enterprises",
|
418 |
+
"email": "security@paragonie.com",
|
419 |
+
"homepage": "https:\/\/paragonie.com"
|
420 |
+
}
|
421 |
+
],
|
422 |
+
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
423 |
+
"keywords": [
|
424 |
+
"csprng",
|
425 |
+
"polyfill",
|
426 |
+
"pseudorandom",
|
427 |
+
"random"
|
428 |
+
]
|
429 |
+
},
|
430 |
+
{
|
431 |
+
"name": "psr\/http-message",
|
432 |
+
"version": "1.0.1",
|
433 |
+
"version_normalized": "1.0.1.0",
|
434 |
+
"source": {
|
435 |
+
"type": "git",
|
436 |
+
"url": "https:\/\/github.com\/php-fig\/http-message.git",
|
437 |
+
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
438 |
+
},
|
439 |
+
"dist": {
|
440 |
+
"type": "zip",
|
441 |
+
"url": "https:\/\/api.github.com\/repos\/php-fig\/http-message\/zipball\/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
442 |
+
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
443 |
+
"shasum": ""
|
444 |
+
},
|
445 |
+
"require": {
|
446 |
+
"php": ">=5.3.0"
|
447 |
+
},
|
448 |
+
"time": "2016-08-06T14:39:51+00:00",
|
449 |
+
"type": "library",
|
450 |
+
"extra": {
|
451 |
+
"branch-alias": {
|
452 |
+
"dev-master": "1.0.x-dev"
|
453 |
+
}
|
454 |
+
},
|
455 |
+
"installation-source": "dist",
|
456 |
+
"autoload": {
|
457 |
+
"psr-4": {
|
458 |
+
"PixelCaffeine\\Dependencies\\Psr\\Http\\Message\\": "src\/"
|
459 |
+
}
|
460 |
+
},
|
461 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
462 |
+
"license": [
|
463 |
+
"MIT"
|
464 |
+
],
|
465 |
+
"authors": [
|
466 |
+
{
|
467 |
+
"name": "PHP-FIG",
|
468 |
+
"homepage": "http:\/\/www.php-fig.org\/"
|
469 |
+
}
|
470 |
+
],
|
471 |
+
"description": "Common interface for HTTP messages",
|
472 |
+
"homepage": "https:\/\/github.com\/php-fig\/http-message",
|
473 |
+
"keywords": [
|
474 |
+
"http",
|
475 |
+
"http-message",
|
476 |
+
"psr",
|
477 |
+
"psr-7",
|
478 |
+
"request",
|
479 |
+
"response"
|
480 |
+
]
|
481 |
+
},
|
482 |
+
{
|
483 |
+
"name": "ralouphie\/getallheaders",
|
484 |
+
"version": "3.0.3",
|
485 |
+
"version_normalized": "3.0.3.0",
|
486 |
+
"source": {
|
487 |
+
"type": "git",
|
488 |
+
"url": "https:\/\/github.com\/ralouphie\/getallheaders.git",
|
489 |
+
"reference": "120b605dfeb996808c31b6477290a714d356e822"
|
490 |
+
},
|
491 |
+
"dist": {
|
492 |
+
"type": "zip",
|
493 |
+
"url": "https:\/\/api.github.com\/repos\/ralouphie\/getallheaders\/zipball\/120b605dfeb996808c31b6477290a714d356e822",
|
494 |
+
"reference": "120b605dfeb996808c31b6477290a714d356e822",
|
495 |
+
"shasum": ""
|
496 |
+
},
|
497 |
+
"require": {
|
498 |
+
"php": ">=5.6"
|
499 |
+
},
|
500 |
+
"require-dev": {
|
501 |
+
"php-coveralls\/php-coveralls": "^2.1",
|
502 |
+
"phpunit\/phpunit": "^5 || ^6.5"
|
503 |
+
},
|
504 |
+
"time": "2019-03-08T08:55:37+00:00",
|
505 |
+
"type": "library",
|
506 |
+
"installation-source": "dist",
|
507 |
+
"autoload": {
|
508 |
+
"files": [
|
509 |
+
"src\/getallheaders.php"
|
510 |
+
]
|
511 |
+
},
|
512 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
513 |
+
"license": [
|
514 |
+
"MIT"
|
515 |
+
],
|
516 |
+
"authors": [
|
517 |
+
{
|
518 |
+
"name": "Ralph Khattar",
|
519 |
+
"email": "ralph.khattar@gmail.com"
|
520 |
+
}
|
521 |
+
],
|
522 |
+
"description": "A polyfill for getallheaders."
|
523 |
+
},
|
524 |
+
{
|
525 |
+
"name": "ramsey\/uuid",
|
526 |
+
"version": "3.9.3",
|
527 |
+
"version_normalized": "3.9.3.0",
|
528 |
+
"source": {
|
529 |
+
"type": "git",
|
530 |
+
"url": "https:\/\/github.com\/ramsey\/uuid.git",
|
531 |
+
"reference": "7e1633a6964b48589b142d60542f9ed31bd37a92"
|
532 |
+
},
|
533 |
+
"dist": {
|
534 |
+
"type": "zip",
|
535 |
+
"url": "https:\/\/api.github.com\/repos\/ramsey\/uuid\/zipball\/7e1633a6964b48589b142d60542f9ed31bd37a92",
|
536 |
+
"reference": "7e1633a6964b48589b142d60542f9ed31bd37a92",
|
537 |
+
"shasum": ""
|
538 |
+
},
|
539 |
+
"require": {
|
540 |
+
"ext-json": "*",
|
541 |
+
"paragonie\/random_compat": "^1 | ^2 | 9.99.99",
|
542 |
+
"php": "^5.4 | ^7 | ^8",
|
543 |
+
"symfony\/polyfill-ctype": "^1.8"
|
544 |
+
},
|
545 |
+
"replace": {
|
546 |
+
"rhumsaa\/uuid": "self.version"
|
547 |
+
},
|
548 |
+
"require-dev": {
|
549 |
+
"codeception\/aspect-mock": "^1 | ^2",
|
550 |
+
"doctrine\/annotations": "^1.2",
|
551 |
+
"goaop\/framework": "1.0.0-alpha.2 | ^1 | ^2.1",
|
552 |
+
"jakub-onderka\/php-parallel-lint": "^1",
|
553 |
+
"mockery\/mockery": "^0.9.11 | ^1",
|
554 |
+
"moontoast\/math": "^1.1",
|
555 |
+
"paragonie\/random-lib": "^2",
|
556 |
+
"php-mock\/php-mock-phpunit": "^0.3 | ^1.1",
|
557 |
+
"phpunit\/phpunit": "^4.8 | ^5.4 | ^6.5",
|
558 |
+
"squizlabs\/php_codesniffer": "^3.5"
|
559 |
+
},
|
560 |
+
"suggest": {
|
561 |
+
"ext-ctype": "Provides support for PHP Ctype functions",
|
562 |
+
"ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator",
|
563 |
+
"ext-openssl": "Provides the OpenSSL extension for use with the OpenSslGenerator",
|
564 |
+
"ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator",
|
565 |
+
"moontoast\/math": "Provides support for converting UUID to 128-bit integer (in string form).",
|
566 |
+
"paragonie\/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
|
567 |
+
"ramsey\/uuid-console": "A console application for generating UUIDs with ramsey\/uuid",
|
568 |
+
"ramsey\/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
|
569 |
+
},
|
570 |
+
"time": "2020-02-21T04:36:14+00:00",
|
571 |
+
"type": "library",
|
572 |
+
"extra": {
|
573 |
+
"branch-alias": {
|
574 |
+
"dev-master": "3.x-dev"
|
575 |
+
}
|
576 |
+
},
|
577 |
+
"installation-source": "dist",
|
578 |
+
"autoload": {
|
579 |
+
"psr-4": {
|
580 |
+
"PixelCaffeine\\Dependencies\\Ramsey\\Uuid\\": "src\/"
|
581 |
+
},
|
582 |
+
"files": [
|
583 |
+
"src\/functions.php"
|
584 |
+
]
|
585 |
+
},
|
586 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
587 |
+
"license": [
|
588 |
+
"MIT"
|
589 |
+
],
|
590 |
+
"authors": [
|
591 |
+
{
|
592 |
+
"name": "Ben Ramsey",
|
593 |
+
"email": "ben@benramsey.com",
|
594 |
+
"homepage": "https:\/\/benramsey.com"
|
595 |
+
},
|
596 |
+
{
|
597 |
+
"name": "Marijn Huizendveld",
|
598 |
+
"email": "marijn.huizendveld@gmail.com"
|
599 |
+
},
|
600 |
+
{
|
601 |
+
"name": "Thibaud Fabre",
|
602 |
+
"email": "thibaud@aztech.io"
|
603 |
+
}
|
604 |
+
],
|
605 |
+
"description": "Formerly rhumsaa\/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
|
606 |
+
"homepage": "https:\/\/github.com\/ramsey\/uuid",
|
607 |
+
"keywords": [
|
608 |
+
"guid",
|
609 |
+
"identifier",
|
610 |
+
"uuid"
|
611 |
+
]
|
612 |
+
},
|
613 |
+
{
|
614 |
+
"name": "symfony\/filesystem",
|
615 |
+
"version": "v2.8.52",
|
616 |
+
"version_normalized": "2.8.52.0",
|
617 |
+
"source": {
|
618 |
+
"type": "git",
|
619 |
+
"url": "https:\/\/github.com\/symfony\/filesystem.git",
|
620 |
+
"reference": "7ae46872dad09dffb7fe1e93a0937097339d0080"
|
621 |
+
},
|
622 |
+
"dist": {
|
623 |
+
"type": "zip",
|
624 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/7ae46872dad09dffb7fe1e93a0937097339d0080",
|
625 |
+
"reference": "7ae46872dad09dffb7fe1e93a0937097339d0080",
|
626 |
+
"shasum": ""
|
627 |
+
},
|
628 |
+
"require": {
|
629 |
+
"php": ">=5.3.9",
|
630 |
+
"symfony\/polyfill-ctype": "~1.8"
|
631 |
+
},
|
632 |
+
"time": "2018-11-11T11:18:13+00:00",
|
633 |
+
"type": "library",
|
634 |
+
"extra": {
|
635 |
+
"branch-alias": {
|
636 |
+
"dev-master": "2.8-dev"
|
637 |
+
}
|
638 |
+
},
|
639 |
+
"installation-source": "dist",
|
640 |
+
"autoload": {
|
641 |
+
"psr-4": {
|
642 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Component\\Filesystem\\": ""
|
643 |
+
},
|
644 |
+
"exclude-from-classmap": [
|
645 |
+
"\/Tests\/"
|
646 |
+
]
|
647 |
+
},
|
648 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
649 |
+
"license": [
|
650 |
+
"MIT"
|
651 |
+
],
|
652 |
+
"authors": [
|
653 |
+
{
|
654 |
+
"name": "Fabien Potencier",
|
655 |
+
"email": "fabien@symfony.com"
|
656 |
+
},
|
657 |
+
{
|
658 |
+
"name": "Symfony Community",
|
659 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
660 |
+
}
|
661 |
+
],
|
662 |
+
"description": "Symfony Filesystem Component",
|
663 |
+
"homepage": "https:\/\/symfony.com"
|
664 |
+
},
|
665 |
+
{
|
666 |
+
"name": "symfony\/polyfill-ctype",
|
667 |
+
"version": "v1.19.0",
|
668 |
+
"version_normalized": "1.19.0.0",
|
669 |
+
"source": {
|
670 |
+
"type": "git",
|
671 |
+
"url": "https:\/\/github.com\/symfony\/polyfill-ctype.git",
|
672 |
+
"reference": "aed596913b70fae57be53d86faa2e9ef85a2297b"
|
673 |
+
},
|
674 |
+
"dist": {
|
675 |
+
"type": "zip",
|
676 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-ctype\/zipball\/aed596913b70fae57be53d86faa2e9ef85a2297b",
|
677 |
+
"reference": "aed596913b70fae57be53d86faa2e9ef85a2297b",
|
678 |
+
"shasum": ""
|
679 |
+
},
|
680 |
+
"require": {
|
681 |
+
"php": ">=5.3.3"
|
682 |
+
},
|
683 |
+
"suggest": {
|
684 |
+
"ext-ctype": "For best performance"
|
685 |
+
},
|
686 |
+
"time": "2020-10-23T09:01:57+00:00",
|
687 |
+
"type": "library",
|
688 |
+
"extra": {
|
689 |
+
"branch-alias": {
|
690 |
+
"dev-main": "1.19-dev"
|
691 |
+
},
|
692 |
+
"thanks": {
|
693 |
+
"name": "symfony\/polyfill",
|
694 |
+
"url": "https:\/\/github.com\/symfony\/polyfill"
|
695 |
+
}
|
696 |
+
},
|
697 |
+
"installation-source": "dist",
|
698 |
+
"autoload": {
|
699 |
+
"psr-4": {
|
700 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Ctype\\": ""
|
701 |
+
},
|
702 |
+
"files": [
|
703 |
+
"bootstrap.php"
|
704 |
+
]
|
705 |
+
},
|
706 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
707 |
+
"license": [
|
708 |
+
"MIT"
|
709 |
+
],
|
710 |
+
"authors": [
|
711 |
+
{
|
712 |
+
"name": "Gert de Pagter",
|
713 |
+
"email": "BackEndTea@gmail.com"
|
714 |
+
},
|
715 |
+
{
|
716 |
+
"name": "Symfony Community",
|
717 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
718 |
+
}
|
719 |
+
],
|
720 |
+
"description": "Symfony polyfill for ctype functions",
|
721 |
+
"homepage": "https:\/\/symfony.com",
|
722 |
+
"keywords": [
|
723 |
+
"compatibility",
|
724 |
+
"ctype",
|
725 |
+
"polyfill",
|
726 |
+
"portable"
|
727 |
+
]
|
728 |
+
},
|
729 |
+
{
|
730 |
+
"name": "symfony\/polyfill-intl-idn",
|
731 |
+
"version": "v1.19.0",
|
732 |
+
"version_normalized": "1.19.0.0",
|
733 |
+
"source": {
|
734 |
+
"type": "git",
|
735 |
+
"url": "https:\/\/github.com\/symfony\/polyfill-intl-idn.git",
|
736 |
+
"reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826"
|
737 |
+
},
|
738 |
+
"dist": {
|
739 |
+
"type": "zip",
|
740 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-intl-idn\/zipball\/4ad5115c0f5d5172a9fe8147675ec6de266d8826",
|
741 |
+
"reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826",
|
742 |
+
"shasum": ""
|
743 |
+
},
|
744 |
+
"require": {
|
745 |
+
"php": ">=5.3.3",
|
746 |
+
"symfony\/polyfill-intl-normalizer": "^1.10",
|
747 |
+
"symfony\/polyfill-php70": "^1.10",
|
748 |
+
"symfony\/polyfill-php72": "^1.10"
|
749 |
+
},
|
750 |
+
"suggest": {
|
751 |
+
"ext-intl": "For best performance"
|
752 |
+
},
|
753 |
+
"time": "2020-10-21T09:57:48+00:00",
|
754 |
+
"type": "library",
|
755 |
+
"extra": {
|
756 |
+
"branch-alias": {
|
757 |
+
"dev-main": "1.19-dev"
|
758 |
+
},
|
759 |
+
"thanks": {
|
760 |
+
"name": "symfony\/polyfill",
|
761 |
+
"url": "https:\/\/github.com\/symfony\/polyfill"
|
762 |
+
}
|
763 |
+
},
|
764 |
+
"installation-source": "dist",
|
765 |
+
"autoload": {
|
766 |
+
"psr-4": {
|
767 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Idn\\": ""
|
768 |
+
},
|
769 |
+
"files": [
|
770 |
+
"bootstrap.php"
|
771 |
+
]
|
772 |
+
},
|
773 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
774 |
+
"license": [
|
775 |
+
"MIT"
|
776 |
+
],
|
777 |
+
"authors": [
|
778 |
+
{
|
779 |
+
"name": "Laurent Bassin",
|
780 |
+
"email": "laurent@bassin.info"
|
781 |
+
},
|
782 |
+
{
|
783 |
+
"name": "Trevor Rowbotham",
|
784 |
+
"email": "trevor.rowbotham@pm.me"
|
785 |
+
},
|
786 |
+
{
|
787 |
+
"name": "Symfony Community",
|
788 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
789 |
+
}
|
790 |
+
],
|
791 |
+
"description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions",
|
792 |
+
"homepage": "https:\/\/symfony.com",
|
793 |
+
"keywords": [
|
794 |
+
"compatibility",
|
795 |
+
"idn",
|
796 |
+
"intl",
|
797 |
+
"polyfill",
|
798 |
+
"portable",
|
799 |
+
"shim"
|
800 |
+
],
|
801 |
+
"funding": [
|
802 |
+
{
|
803 |
+
"url": "https:\/\/symfony.com\/sponsor",
|
804 |
+
"type": "custom"
|
805 |
+
},
|
806 |
+
{
|
807 |
+
"url": "https:\/\/github.com\/fabpot",
|
808 |
+
"type": "github"
|
809 |
+
},
|
810 |
+
{
|
811 |
+
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/symfony\/symfony",
|
812 |
+
"type": "tidelift"
|
813 |
+
}
|
814 |
+
]
|
815 |
+
},
|
816 |
+
{
|
817 |
+
"name": "symfony\/polyfill-intl-normalizer",
|
818 |
+
"version": "v1.19.0",
|
819 |
+
"version_normalized": "1.19.0.0",
|
820 |
+
"source": {
|
821 |
+
"type": "git",
|
822 |
+
"url": "https:\/\/github.com\/symfony\/polyfill-intl-normalizer.git",
|
823 |
+
"reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27"
|
824 |
+
},
|
825 |
+
"dist": {
|
826 |
+
"type": "zip",
|
827 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-intl-normalizer\/zipball\/8db0ae7936b42feb370840cf24de1a144fb0ef27",
|
828 |
+
"reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27",
|
829 |
+
"shasum": ""
|
830 |
+
},
|
831 |
+
"require": {
|
832 |
+
"php": ">=5.3.3"
|
833 |
+
},
|
834 |
+
"suggest": {
|
835 |
+
"ext-intl": "For best performance"
|
836 |
+
},
|
837 |
+
"time": "2020-10-23T09:01:57+00:00",
|
838 |
+
"type": "library",
|
839 |
+
"extra": {
|
840 |
+
"branch-alias": {
|
841 |
+
"dev-main": "1.19-dev"
|
842 |
+
},
|
843 |
+
"thanks": {
|
844 |
+
"name": "symfony\/polyfill",
|
845 |
+
"url": "https:\/\/github.com\/symfony\/polyfill"
|
846 |
+
}
|
847 |
+
},
|
848 |
+
"installation-source": "dist",
|
849 |
+
"autoload": {
|
850 |
+
"psr-4": {
|
851 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Intl\\Normalizer\\": ""
|
852 |
+
},
|
853 |
+
"files": [
|
854 |
+
"bootstrap.php"
|
855 |
+
],
|
856 |
+
"classmap": [
|
857 |
+
"Resources\/stubs"
|
858 |
+
]
|
859 |
+
},
|
860 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
861 |
+
"license": [
|
862 |
+
"MIT"
|
863 |
+
],
|
864 |
+
"authors": [
|
865 |
+
{
|
866 |
+
"name": "Nicolas Grekas",
|
867 |
+
"email": "p@tchwork.com"
|
868 |
+
},
|
869 |
+
{
|
870 |
+
"name": "Symfony Community",
|
871 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
872 |
+
}
|
873 |
+
],
|
874 |
+
"description": "Symfony polyfill for intl's Normalizer class and related functions",
|
875 |
+
"homepage": "https:\/\/symfony.com",
|
876 |
+
"keywords": [
|
877 |
+
"compatibility",
|
878 |
+
"intl",
|
879 |
+
"normalizer",
|
880 |
+
"polyfill",
|
881 |
+
"portable",
|
882 |
+
"shim"
|
883 |
+
],
|
884 |
+
"funding": [
|
885 |
+
{
|
886 |
+
"url": "https:\/\/symfony.com\/sponsor",
|
887 |
+
"type": "custom"
|
888 |
+
},
|
889 |
+
{
|
890 |
+
"url": "https:\/\/github.com\/fabpot",
|
891 |
+
"type": "github"
|
892 |
+
},
|
893 |
+
{
|
894 |
+
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/symfony\/symfony",
|
895 |
+
"type": "tidelift"
|
896 |
+
}
|
897 |
+
]
|
898 |
+
},
|
899 |
+
{
|
900 |
+
"name": "symfony\/polyfill-php70",
|
901 |
+
"version": "v1.19.0",
|
902 |
+
"version_normalized": "1.19.0.0",
|
903 |
+
"source": {
|
904 |
+
"type": "git",
|
905 |
+
"url": "https:\/\/github.com\/symfony\/polyfill-php70.git",
|
906 |
+
"reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e"
|
907 |
+
},
|
908 |
+
"dist": {
|
909 |
+
"type": "zip",
|
910 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-php70\/zipball\/3fe414077251a81a1b15b1c709faf5c2fbae3d4e",
|
911 |
+
"reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e",
|
912 |
+
"shasum": ""
|
913 |
+
},
|
914 |
+
"require": {
|
915 |
+
"paragonie\/random_compat": "~1.0|~2.0|~9.99",
|
916 |
+
"php": ">=5.3.3"
|
917 |
+
},
|
918 |
+
"time": "2020-10-23T09:01:57+00:00",
|
919 |
+
"type": "library",
|
920 |
+
"extra": {
|
921 |
+
"branch-alias": {
|
922 |
+
"dev-main": "1.19-dev"
|
923 |
+
},
|
924 |
+
"thanks": {
|
925 |
+
"name": "symfony\/polyfill",
|
926 |
+
"url": "https:\/\/github.com\/symfony\/polyfill"
|
927 |
+
}
|
928 |
+
},
|
929 |
+
"installation-source": "dist",
|
930 |
+
"autoload": {
|
931 |
+
"psr-4": {
|
932 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php70\\": ""
|
933 |
+
},
|
934 |
+
"files": [
|
935 |
+
"bootstrap.php"
|
936 |
+
],
|
937 |
+
"classmap": [
|
938 |
+
"Resources\/stubs"
|
939 |
+
]
|
940 |
+
},
|
941 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
942 |
+
"license": [
|
943 |
+
"MIT"
|
944 |
+
],
|
945 |
+
"authors": [
|
946 |
+
{
|
947 |
+
"name": "Nicolas Grekas",
|
948 |
+
"email": "p@tchwork.com"
|
949 |
+
},
|
950 |
+
{
|
951 |
+
"name": "Symfony Community",
|
952 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
953 |
+
}
|
954 |
+
],
|
955 |
+
"description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions",
|
956 |
+
"homepage": "https:\/\/symfony.com",
|
957 |
+
"keywords": [
|
958 |
+
"compatibility",
|
959 |
+
"polyfill",
|
960 |
+
"portable",
|
961 |
+
"shim"
|
962 |
+
],
|
963 |
+
"funding": [
|
964 |
+
{
|
965 |
+
"url": "https:\/\/symfony.com\/sponsor",
|
966 |
+
"type": "custom"
|
967 |
+
},
|
968 |
+
{
|
969 |
+
"url": "https:\/\/github.com\/fabpot",
|
970 |
+
"type": "github"
|
971 |
+
},
|
972 |
+
{
|
973 |
+
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/symfony\/symfony",
|
974 |
+
"type": "tidelift"
|
975 |
+
}
|
976 |
+
]
|
977 |
+
},
|
978 |
+
{
|
979 |
+
"name": "symfony\/polyfill-php72",
|
980 |
+
"version": "v1.19.0",
|
981 |
+
"version_normalized": "1.19.0.0",
|
982 |
+
"source": {
|
983 |
+
"type": "git",
|
984 |
+
"url": "https:\/\/github.com\/symfony\/polyfill-php72.git",
|
985 |
+
"reference": "beecef6b463b06954638f02378f52496cb84bacc"
|
986 |
+
},
|
987 |
+
"dist": {
|
988 |
+
"type": "zip",
|
989 |
+
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-php72\/zipball\/beecef6b463b06954638f02378f52496cb84bacc",
|
990 |
+
"reference": "beecef6b463b06954638f02378f52496cb84bacc",
|
991 |
+
"shasum": ""
|
992 |
+
},
|
993 |
+
"require": {
|
994 |
+
"php": ">=5.3.3"
|
995 |
+
},
|
996 |
+
"time": "2020-10-23T09:01:57+00:00",
|
997 |
+
"type": "library",
|
998 |
+
"extra": {
|
999 |
+
"branch-alias": {
|
1000 |
+
"dev-main": "1.19-dev"
|
1001 |
+
},
|
1002 |
+
"thanks": {
|
1003 |
+
"name": "symfony\/polyfill",
|
1004 |
+
"url": "https:\/\/github.com\/symfony\/polyfill"
|
1005 |
+
}
|
1006 |
+
},
|
1007 |
+
"installation-source": "dist",
|
1008 |
+
"autoload": {
|
1009 |
+
"psr-4": {
|
1010 |
+
"PixelCaffeine\\Dependencies\\Symfony\\Polyfill\\Php72\\": ""
|
1011 |
+
},
|
1012 |
+
"files": [
|
1013 |
+
"bootstrap.php"
|
1014 |
+
]
|
1015 |
+
},
|
1016 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
1017 |
+
"license": [
|
1018 |
+
"MIT"
|
1019 |
+
],
|
1020 |
+
"authors": [
|
1021 |
+
{
|
1022 |
+
"name": "Nicolas Grekas",
|
1023 |
+
"email": "p@tchwork.com"
|
1024 |
+
},
|
1025 |
+
{
|
1026 |
+
"name": "Symfony Community",
|
1027 |
+
"homepage": "https:\/\/symfony.com\/contributors"
|
1028 |
+
}
|
1029 |
+
],
|
1030 |
+
"description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
|
1031 |
+
"homepage": "https:\/\/symfony.com",
|
1032 |
+
"keywords": [
|
1033 |
+
"compatibility",
|
1034 |
+
"polyfill",
|
1035 |
+
"portable",
|
1036 |
+
"shim"
|
1037 |
+
],
|
1038 |
+
"funding": [
|
1039 |
+
{
|
1040 |
+
"url": "https:\/\/symfony.com\/sponsor",
|
1041 |
+
"type": "custom"
|
1042 |
+
},
|
1043 |
+
{
|
1044 |
+
"url": "https:\/\/github.com\/fabpot",
|
1045 |
+
"type": "github"
|
1046 |
+
},
|
1047 |
+
{
|
1048 |
+
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/symfony\/symfony",
|
1049 |
+
"type": "tidelift"
|
1050 |
+
}
|
1051 |
+
]
|
1052 |
+
},
|
1053 |
+
{
|
1054 |
+
"name": "togos\/gitignore",
|
1055 |
+
"version": "1.1.1",
|
1056 |
+
"version_normalized": "1.1.1.0",
|
1057 |
+
"source": {
|
1058 |
+
"type": "git",
|
1059 |
+
"url": "https:\/\/github.com\/TOGoS\/PHPGitIgnore.git",
|
1060 |
+
"reference": "32bc0830e4123f670adcbf5ddda5bef362f4f4d4"
|
1061 |
+
},
|
1062 |
+
"dist": {
|
1063 |
+
"type": "zip",
|
1064 |
+
"url": "https:\/\/api.github.com\/repos\/TOGoS\/PHPGitIgnore\/zipball\/32bc0830e4123f670adcbf5ddda5bef362f4f4d4",
|
1065 |
+
"reference": "32bc0830e4123f670adcbf5ddda5bef362f4f4d4",
|
1066 |
+
"shasum": ""
|
1067 |
+
},
|
1068 |
+
"require": {
|
1069 |
+
"php": ">=5.2"
|
1070 |
+
},
|
1071 |
+
"require-dev": {
|
1072 |
+
"togos\/simpler-test": "1.1.1"
|
1073 |
+
},
|
1074 |
+
"time": "2019-04-19T19:16:58+00:00",
|
1075 |
+
"type": "library",
|
1076 |
+
"installation-source": "dist",
|
1077 |
+
"autoload": {
|
1078 |
+
"classmap": [
|
1079 |
+
"src\/main\/php\/"
|
1080 |
+
]
|
1081 |
+
},
|
1082 |
+
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
1083 |
+
"license": [
|
1084 |
+
"MIT"
|
1085 |
+
],
|
1086 |
+
"description": "Parser for .gitignore (and sparse-checkout, and anything else using the same format) files"
|
1087 |
+
}
|
1088 |
+
]
|
{vendor → third-party/vendor}/facebook/php-business-sdk/fb_ca_chain_bundle.crt
RENAMED
File without changes
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/AnonymousSession.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,15 +22,15 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
}
|
35 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
|
27 |
+
class AnonymousSession implements \PixelCaffeine\Dependencies\FacebookAds\SessionInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function getRequestParameters()
|
33 |
+
{
|
34 |
+
return array();
|
35 |
+
}
|
|
|
36 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Logger\LoggerInterface;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Logger\NullLogger;
|
32 |
+
use PixelCaffeine\Dependencies\FacebookAds\CrashReporter;
|
33 |
+
class Api
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
const VERSION = \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::APIVersion;
|
39 |
+
/**
|
40 |
+
* @var Api
|
41 |
+
*/
|
42 |
+
protected static $instance;
|
43 |
+
/**
|
44 |
+
* @var SessionInterface
|
45 |
+
*/
|
46 |
+
private $session;
|
47 |
+
/**
|
48 |
+
* @var LoggerInterface
|
49 |
+
*/
|
50 |
+
protected $logger;
|
51 |
+
/**
|
52 |
+
* @var Client
|
53 |
+
*/
|
54 |
+
protected $httpClient;
|
55 |
+
/**
|
56 |
+
* @var string
|
57 |
+
*/
|
58 |
+
protected $defaultGraphVersion;
|
59 |
+
/**
|
60 |
+
* @param Client $http_client
|
61 |
+
* @param SessionInterface $session A Facebook API session
|
62 |
+
*/
|
63 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $http_client, \PixelCaffeine\Dependencies\FacebookAds\SessionInterface $session)
|
64 |
+
{
|
65 |
+
$this->httpClient = $http_client;
|
66 |
+
$this->session = $session;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* @param string $app_id
|
70 |
+
* @param string $app_secret
|
71 |
+
* @param string $access_token
|
72 |
+
* @return static
|
73 |
+
*/
|
74 |
+
public static function init($app_id, $app_secret, $access_token, $log_crash = \true)
|
75 |
+
{
|
76 |
+
$session = new \PixelCaffeine\Dependencies\FacebookAds\Session($app_id, $app_secret, $access_token);
|
77 |
+
$api = new static(new \PixelCaffeine\Dependencies\FacebookAds\Http\Client(), $session);
|
78 |
+
static::setInstance($api);
|
79 |
+
if ($log_crash) {
|
80 |
+
\PixelCaffeine\Dependencies\FacebookAds\CrashReporter::enable();
|
81 |
+
}
|
82 |
+
return $api;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* @return Api|null
|
86 |
+
*/
|
87 |
+
public static function instance()
|
88 |
+
{
|
89 |
+
return static::$instance;
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* @param Api $instance
|
93 |
+
*/
|
94 |
+
public static function setInstance(\PixelCaffeine\Dependencies\FacebookAds\Api $instance)
|
95 |
+
{
|
96 |
+
static::$instance = $instance;
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* @param SessionInterface $session
|
100 |
+
* @return Api
|
101 |
+
*/
|
102 |
+
public function getCopyWithSession(\PixelCaffeine\Dependencies\FacebookAds\SessionInterface $session)
|
103 |
+
{
|
104 |
+
$api = new self($this->getHttpClient(), $session);
|
105 |
+
$api->setDefaultGraphVersion($this->getDefaultGraphVersion());
|
106 |
+
$api->setLogger($this->getLogger());
|
107 |
+
return $api;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* @param string $string
|
111 |
+
* @return string
|
112 |
+
*/
|
113 |
+
public static function base64UrlEncode($string)
|
114 |
+
{
|
115 |
+
$str = \strtr(\base64_encode($string), '+/', '-_');
|
116 |
+
$str = \str_replace('=', '', $str);
|
117 |
+
return $str;
|
118 |
+
}
|
119 |
+
/**
|
120 |
+
* @param string $path
|
121 |
+
* @param string $method
|
122 |
+
* @param array $params
|
123 |
+
* @return RequestInterface
|
124 |
+
*/
|
125 |
+
public function prepareRequest($path, $method = \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, array $params = array())
|
126 |
+
{
|
127 |
+
$request = $this->getHttpClient()->createRequest();
|
128 |
+
$request->setMethod($method);
|
129 |
+
$request->setGraphVersion($this->getDefaultGraphVersion());
|
130 |
+
$request->setPath($path);
|
131 |
+
if ($method === \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET) {
|
132 |
+
$params_ref = $request->getQueryParams();
|
133 |
+
} else {
|
134 |
+
$params_ref = $request->getBodyParams();
|
135 |
+
}
|
136 |
+
if (!empty($params)) {
|
137 |
+
$params_ref->enhance($params);
|
138 |
+
}
|
139 |
+
$params_ref->enhance($this->getSession()->getRequestParameters());
|
140 |
+
return $request;
|
141 |
+
}
|
142 |
+
/**
|
143 |
+
* @param RequestInterface $request
|
144 |
+
* @return ResponseInterface
|
145 |
+
*/
|
146 |
+
public function executeRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request)
|
147 |
+
{
|
148 |
+
$this->getLogger()->logRequest('debug', $request);
|
149 |
+
$response = $request->execute();
|
150 |
+
$this->getLogger()->logResponse('debug', $response);
|
151 |
+
return $response;
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
public function getDefaultGraphVersion()
|
157 |
+
{
|
158 |
+
if ($this->defaultGraphVersion === null) {
|
159 |
+
$match = array();
|
160 |
+
if (\preg_match("/^\\d+\\.\\d+/", static::VERSION, $match)) {
|
161 |
+
$this->defaultGraphVersion = $match[0];
|
162 |
+
}
|
163 |
+
}
|
164 |
+
return $this->defaultGraphVersion;
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* @param string $version
|
168 |
+
*/
|
169 |
+
public function setDefaultGraphVersion($version)
|
170 |
+
{
|
171 |
+
$this->defaultGraphVersion = $version;
|
172 |
+
}
|
173 |
+
/**
|
174 |
+
* Make graph api calls
|
175 |
+
*
|
176 |
+
* @param string $path Ads API endpoint
|
177 |
+
* @param string $method Ads API request type
|
178 |
+
* @param array $params Assoc of request parameters
|
179 |
+
* @return ResponseInterface Graph API responses
|
180 |
+
*/
|
181 |
+
public function call($path, $method = \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, array $params = array(), array $file_params = array())
|
182 |
+
{
|
183 |
+
$request = $this->prepareRequest($path, $method, $params);
|
184 |
+
if (!empty($file_params)) {
|
185 |
+
foreach ($file_params as $key => $value) {
|
186 |
+
$request->getFileParams()->offsetSet($key, $value);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
return $this->executeRequest($request);
|
190 |
+
}
|
191 |
+
/**
|
192 |
+
* @return SessionInterface
|
193 |
+
*/
|
194 |
+
public function getSession()
|
195 |
+
{
|
196 |
+
return $this->session;
|
197 |
+
}
|
198 |
+
/**
|
199 |
+
* @param LoggerInterface $logger
|
200 |
+
*/
|
201 |
+
public function setLogger(\PixelCaffeine\Dependencies\FacebookAds\Logger\LoggerInterface $logger)
|
202 |
+
{
|
203 |
+
$this->logger = $logger;
|
204 |
+
}
|
205 |
+
/**
|
206 |
+
* @return LoggerInterface
|
207 |
+
*/
|
208 |
+
public function getLogger()
|
209 |
+
{
|
210 |
+
if ($this->logger === null) {
|
211 |
+
$this->logger = new \PixelCaffeine\Dependencies\FacebookAds\Logger\NullLogger();
|
212 |
+
}
|
213 |
+
return $this->logger;
|
214 |
+
}
|
215 |
+
/**
|
216 |
+
* @return Client
|
217 |
+
*/
|
218 |
+
public function getHttpClient()
|
219 |
+
{
|
220 |
+
return $this->httpClient;
|
221 |
+
}
|
222 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/ApiConfig.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,11 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
24 |
-
namespace FacebookAds;
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
class ApiConfig
|
28 |
+
{
|
29 |
+
const APIVersion = '9.0';
|
30 |
+
const SDKVersion = '9.0.4';
|
31 |
+
const TYPE_CHECKER_STRICT_MODE = \false;
|
32 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/ApiRequest.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Cursor;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\AbstractObject;
|
29 |
+
class ApiRequest
|
30 |
+
{
|
31 |
+
protected $api;
|
32 |
+
protected $id;
|
33 |
+
protected $method;
|
34 |
+
protected $endpoint;
|
35 |
+
protected $return_prototype;
|
36 |
+
protected $accepted_fields;
|
37 |
+
protected $param_checker;
|
38 |
+
protected $api_type;
|
39 |
+
protected $use_graph_video_endpoint;
|
40 |
+
private $fields;
|
41 |
+
private $params;
|
42 |
+
private $file_params;
|
43 |
+
private $allow_file_upload;
|
44 |
+
private $file_counter;
|
45 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Api $api, $id, $method, $endpoint, $return_prototype = null, $api_type = null, $accepted_fields = array(), \PixelCaffeine\Dependencies\FacebookAds\TypeChecker $param_checker = null, $allow_file_upload = \false, $use_graph_video_endpoint = \false)
|
46 |
+
{
|
47 |
+
$this->fields = [];
|
48 |
+
$this->params = [];
|
49 |
+
$this->file_params = [];
|
50 |
+
$this->file_counter = 0;
|
51 |
+
$this->api = $api;
|
52 |
+
$this->id = $id;
|
53 |
+
$this->method = $method;
|
54 |
+
$this->endpoint = $endpoint;
|
55 |
+
$this->return_prototype = $return_prototype;
|
56 |
+
$this->api_type = $api_type;
|
57 |
+
$this->accepted_fields = $accepted_fields;
|
58 |
+
$this->param_checker = $param_checker;
|
59 |
+
$this->allow_file_upload = $allow_file_upload;
|
60 |
+
$this->use_graph_video_endpoint = $use_graph_video_endpoint;
|
61 |
+
}
|
62 |
+
public function addParam($param, $value)
|
63 |
+
{
|
64 |
+
$extracted_value = $this->extractValue($value);
|
65 |
+
if (!\PixelCaffeine\Dependencies\FacebookAds\ApiConfig::TYPE_CHECKER_STRICT_MODE || !$this->param_checker->isValidParam($param)) {
|
66 |
+
if ($this->param_checker->isFileParam($param)) {
|
67 |
+
$this->file_params[$param] = $extracted_value;
|
68 |
+
} else {
|
69 |
+
$this->params[$param] = $extracted_value;
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
if ($this->param_checker->isValidParamPair($param, $value)) {
|
73 |
+
if ($this->param_checker->isFileParam($param)) {
|
74 |
+
$this->file_params[$param] = $extracted_value;
|
75 |
+
} else {
|
76 |
+
$this->params[$param] = $extracted_value;
|
77 |
+
}
|
78 |
+
} elseif ($this->param_checker->isPrimitiveType($param)) {
|
79 |
+
$param_type = $this->param_checker->getType($param);
|
80 |
+
$this->params[$param] = $this->param_checker->convertStringToPrimType($param_type, $value);
|
81 |
+
} else {
|
82 |
+
throw new \LogicException('The value for ' . $param . ' is not compatible');
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
public function addParams($params)
|
88 |
+
{
|
89 |
+
foreach ($params as $key => $value) {
|
90 |
+
$this->addParam($key, $value);
|
91 |
+
}
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
public function removeParam($param)
|
95 |
+
{
|
96 |
+
if (\array_key_exists($param, $this->params)) {
|
97 |
+
unset($this->params[$param]);
|
98 |
+
} elseif (\array_key_exists($param, $this->params)) {
|
99 |
+
unset($this->file_params[$param]);
|
100 |
+
}
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
public function clearParams()
|
104 |
+
{
|
105 |
+
$this->params = [];
|
106 |
+
$this->file_params = [];
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
public function getParams()
|
110 |
+
{
|
111 |
+
$all_params = \array_merge($this->params, $this->file_params);
|
112 |
+
return $all_params;
|
113 |
+
}
|
114 |
+
public function addField($field)
|
115 |
+
{
|
116 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\ApiConfig::TYPE_CHECKER_STRICT_MODE && !\in_array($field, $this->accepted_fields)) {
|
117 |
+
throw new \LogicException('Field ' . $field . ' is not supported');
|
118 |
+
}
|
119 |
+
if (!\in_array($field, $this->fields)) {
|
120 |
+
$this->fields[] = $field;
|
121 |
+
}
|
122 |
+
return $this;
|
123 |
+
}
|
124 |
+
public function addFields($fields)
|
125 |
+
{
|
126 |
+
foreach ($fields as $field) {
|
127 |
+
$this->addField($field);
|
128 |
+
}
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
public function removeField($field)
|
132 |
+
{
|
133 |
+
if (\in_array($field, $this->fields)) {
|
134 |
+
$index_to_remove = \array_search($field, $this->fields);
|
135 |
+
unset($this->fields[$index_to_remove]);
|
136 |
+
}
|
137 |
+
return $this;
|
138 |
+
}
|
139 |
+
public function clearFields()
|
140 |
+
{
|
141 |
+
$this->fields = [];
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
public function getFields()
|
145 |
+
{
|
146 |
+
return $this->fields;
|
147 |
+
}
|
148 |
+
public function addFile($filename)
|
149 |
+
{
|
150 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\ApiConfig::TYPE_CHECKER_STRICT_MODE && !$this->allow_file_upload) {
|
151 |
+
throw new \LogicException("This api cannot upload files");
|
152 |
+
}
|
153 |
+
$file_key = 'source' . $this->file_counter;
|
154 |
+
if (\file_exists($filename)) {
|
155 |
+
$this->file_params[$file_key] = $filename;
|
156 |
+
$this->file_counter++;
|
157 |
+
}
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
/**
|
161 |
+
* Execute the request
|
162 |
+
*/
|
163 |
+
public function execute()
|
164 |
+
{
|
165 |
+
$url_path = '/' . $this->id . $this->endpoint;
|
166 |
+
$updated_params = $this->params;
|
167 |
+
if (!empty($this->fields)) {
|
168 |
+
$fields = \implode(',', $this->fields);
|
169 |
+
$updated_params['fields'] = $fields;
|
170 |
+
}
|
171 |
+
$response = $this->api->call($url_path, $this->method, $updated_params, $this->file_params);
|
172 |
+
if ($this->api_type === "EDGE" && $this->method === "GET") {
|
173 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Cursor($response, $this->return_prototype, $this->api);
|
174 |
+
} else {
|
175 |
+
if ($this->method === "DELETE") {
|
176 |
+
return $response;
|
177 |
+
} else {
|
178 |
+
return $this->createObject($response->getContent());
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
protected function extractValue($value)
|
183 |
+
{
|
184 |
+
if ($this->param_checker->isAbstractObject($value)) {
|
185 |
+
return $value->exportAllData();
|
186 |
+
} else {
|
187 |
+
if (\is_array($value)) {
|
188 |
+
$extracted_value = [];
|
189 |
+
foreach ($value as $key => $sub_value) {
|
190 |
+
$extracted_value[$key] = $this->extractValue($sub_value);
|
191 |
+
}
|
192 |
+
return $extracted_value;
|
193 |
+
} else {
|
194 |
+
return $value;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
protected function createObject(array $object_data)
|
199 |
+
{
|
200 |
+
$object = clone $this->return_prototype;
|
201 |
+
$object->setDataWithoutValidation($object_data);
|
202 |
+
if ($object instanceof \PixelCaffeine\Dependencies\FacebookAds\AbstractCrudObject) {
|
203 |
+
$object->setApi($this->api);
|
204 |
+
}
|
205 |
+
return $object;
|
206 |
+
}
|
207 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Exception\Exception;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException;
|
31 |
+
/**
|
32 |
+
* Class CrashReasons
|
33 |
+
* @package FacebookAds
|
34 |
+
*/
|
35 |
+
class CrashReasons
|
36 |
+
{
|
37 |
+
const SDK = 'SDK';
|
38 |
+
const API = 'API';
|
39 |
+
}
|
40 |
+
/**
|
41 |
+
* Class CrashReporter
|
42 |
+
* @package FacebookAds
|
43 |
+
*/
|
44 |
+
class CrashReporter
|
45 |
+
{
|
46 |
+
const E_FATAL = \E_ERROR | \E_USER_ERROR | \E_PARSE | \E_CORE_ERROR | \E_COMPILE_ERROR | \E_RECOVERABLE_ERROR;
|
47 |
+
/**
|
48 |
+
* @var CrashReporter
|
49 |
+
*/
|
50 |
+
private static $instance;
|
51 |
+
/**
|
52 |
+
* @var resource
|
53 |
+
*/
|
54 |
+
private static $handle;
|
55 |
+
/**
|
56 |
+
* @var int
|
57 |
+
*/
|
58 |
+
private $app_id;
|
59 |
+
/**
|
60 |
+
* CrashReporter constructor.
|
61 |
+
* @param int $app_id
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
private function __construct($app_id)
|
65 |
+
{
|
66 |
+
$this->app_id = $app_id;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public static function enable()
|
72 |
+
{
|
73 |
+
if (!static::$handle) {
|
74 |
+
static::$handle = \fopen('php://stdout', 'w');
|
75 |
+
}
|
76 |
+
if (!static::$instance) {
|
77 |
+
$api = \PixelCaffeine\Dependencies\FacebookAds\Api::instance();
|
78 |
+
if ($api == null) {
|
79 |
+
self::log('Could not initialize API' . \PHP_EOL);
|
80 |
+
}
|
81 |
+
static::$instance = new static($api->getSession()->getAppId());
|
82 |
+
static::$instance->registerExceptionHandler();
|
83 |
+
self::log('Enabled' . \PHP_EOL);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* @return void
|
88 |
+
*/
|
89 |
+
public static function disable()
|
90 |
+
{
|
91 |
+
if (static::$instance) {
|
92 |
+
static::$instance = null;
|
93 |
+
\restore_exception_handler();
|
94 |
+
\restore_error_handler();
|
95 |
+
self::log('Disabled');
|
96 |
+
}
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* @param $handle
|
100 |
+
*/
|
101 |
+
public static function setLogger($handle)
|
102 |
+
{
|
103 |
+
if (\is_resource($handle)) {
|
104 |
+
static::$handle = $handle;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
/**
|
108 |
+
* @return void
|
109 |
+
*/
|
110 |
+
private function registerExceptionHandler()
|
111 |
+
{
|
112 |
+
$lastHandler = \set_exception_handler(function (\Throwable $e) use(&$lastHandler) {
|
113 |
+
self::log('Exception detected!');
|
114 |
+
$params = $this->buildParamsFromException($e);
|
115 |
+
if ($params != null) {
|
116 |
+
$this->sendReport(array('bizsdk_crash_report' => $params));
|
117 |
+
}
|
118 |
+
// restore the previous exception
|
119 |
+
if (\is_callable($lastHandler)) {
|
120 |
+
return \call_user_func_array($lastHandler, [$e]);
|
121 |
+
} else {
|
122 |
+
throw $e;
|
123 |
+
}
|
124 |
+
});
|
125 |
+
$lastError = \set_error_handler(function ($errno, $errstr, $errfile, $errline) use(&$lastError) {
|
126 |
+
if ($errno & self::E_FATAL && \strpos($errfile, 'FacebookAds') != \false) {
|
127 |
+
self::log('Error detected!');
|
128 |
+
$e = new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
129 |
+
$params = $this->buildParamsFromException($e);
|
130 |
+
if ($params != null) {
|
131 |
+
$this->sendReport(array('bizsdk_crash_report' => $params));
|
132 |
+
}
|
133 |
+
}
|
134 |
+
if (\is_callable($lastError)) {
|
135 |
+
return \call_user_func_array($lastError, [$errno, $errstr, $errfile, $errline]);
|
136 |
+
} else {
|
137 |
+
// fall through to the standard PHP error handler
|
138 |
+
return \false;
|
139 |
+
}
|
140 |
+
});
|
141 |
+
}
|
142 |
+
/**
|
143 |
+
* @param \Throwable $e
|
144 |
+
* @return array|null
|
145 |
+
*/
|
146 |
+
private function buildParamsFromException(\Throwable $e)
|
147 |
+
{
|
148 |
+
if (!($e instanceof \PixelCaffeine\Dependencies\FacebookAds\Exception\Exception || $e instanceof \ErrorException)) {
|
149 |
+
return NULL;
|
150 |
+
}
|
151 |
+
$reason = \PixelCaffeine\Dependencies\FacebookAds\CrashReasons::SDK;
|
152 |
+
if ($e instanceof \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException) {
|
153 |
+
$reason = \PixelCaffeine\Dependencies\FacebookAds\CrashReasons::API;
|
154 |
+
}
|
155 |
+
$reason .= ' : ' . $e->getMessage();
|
156 |
+
$callstack = \explode(\PHP_EOL, $e->getTraceAsString());
|
157 |
+
return array('reason' => $reason, 'callstack' => $callstack, 'platform' => \phpversion());
|
158 |
+
}
|
159 |
+
/**
|
160 |
+
* @param $params
|
161 |
+
*/
|
162 |
+
private function sendReport($params)
|
163 |
+
{
|
164 |
+
try {
|
165 |
+
$session = new \PixelCaffeine\Dependencies\FacebookAds\AnonymousSession();
|
166 |
+
$api = new \PixelCaffeine\Dependencies\FacebookAds\Api(\PixelCaffeine\Dependencies\FacebookAds\Api::instance()->getHttpClient(), $session);
|
167 |
+
$request = $api->prepareRequest('/' . $this->app_id . '/instruments', \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, $params);
|
168 |
+
$response = $api->executeRequest($request);
|
169 |
+
$data = $response->getContent();
|
170 |
+
if ($data && $data['success']) {
|
171 |
+
self::log('Successfully sent report' . \PHP_EOL);
|
172 |
+
} else {
|
173 |
+
self::log('Failed to send report' . \PHP_EOL);
|
174 |
+
}
|
175 |
+
} catch (\Exception $e) {
|
176 |
+
self::log('Exception on sending report' . \PHP_EOL);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* @param $message
|
181 |
+
*/
|
182 |
+
private static function log($message)
|
183 |
+
{
|
184 |
+
$content = \sprintf("%s : %s%s", static::class, $message, \PHP_EOL);
|
185 |
+
\fwrite(static::$handle, $content);
|
186 |
+
}
|
187 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Cursor.php
ADDED
@@ -0,0 +1,490 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Util;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject;
|
31 |
+
class Cursor implements \Iterator, \Countable, \PixelCaffeine\Dependencies\arrayaccess
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* @var ResponseInterface
|
35 |
+
*/
|
36 |
+
protected $response;
|
37 |
+
/**
|
38 |
+
* @var Api
|
39 |
+
*/
|
40 |
+
protected $api;
|
41 |
+
/**
|
42 |
+
* @var AbstractObject[]
|
43 |
+
*/
|
44 |
+
protected $objects = array();
|
45 |
+
/**
|
46 |
+
* @var int|null
|
47 |
+
*/
|
48 |
+
protected $indexLeft;
|
49 |
+
/**
|
50 |
+
* @var int|null
|
51 |
+
*/
|
52 |
+
protected $indexRight;
|
53 |
+
/**
|
54 |
+
* @var int|null
|
55 |
+
*/
|
56 |
+
protected $position;
|
57 |
+
/**
|
58 |
+
* @var AbstractObject
|
59 |
+
*/
|
60 |
+
protected $objectPrototype;
|
61 |
+
/**
|
62 |
+
* @var bool
|
63 |
+
*/
|
64 |
+
protected static $defaultUseImplicitFetch = \false;
|
65 |
+
/**
|
66 |
+
* @var bool
|
67 |
+
*/
|
68 |
+
protected $useImplicitFetch;
|
69 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response, \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject $object_prototype, \PixelCaffeine\Dependencies\FacebookAds\Api $api = null)
|
70 |
+
{
|
71 |
+
$this->response = $response;
|
72 |
+
$this->objectPrototype = $object_prototype;
|
73 |
+
$this->api = $api !== null ? $api : \PixelCaffeine\Dependencies\FacebookAds\Api::instance();
|
74 |
+
$this->appendResponse($response);
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* @param array $object_data
|
78 |
+
* @return AbstractObject
|
79 |
+
*/
|
80 |
+
protected function createObject(array $object_data)
|
81 |
+
{
|
82 |
+
$object = clone $this->objectPrototype;
|
83 |
+
$object->setDataWithoutValidation($object_data);
|
84 |
+
if ($object instanceof \PixelCaffeine\Dependencies\FacebookAds\AbstractCrudObject) {
|
85 |
+
$object->setApi($this->api);
|
86 |
+
}
|
87 |
+
return $object;
|
88 |
+
}
|
89 |
+
/**
|
90 |
+
* @param ResponseInterface $response
|
91 |
+
* @return array
|
92 |
+
* @throws \InvalidArgumentException
|
93 |
+
*/
|
94 |
+
protected function assureResponseData(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
95 |
+
{
|
96 |
+
$content = $response->getContent();
|
97 |
+
// First, check if the content contains data
|
98 |
+
if (isset($content['data']) && \is_array($content['data'])) {
|
99 |
+
$data = $content['data'];
|
100 |
+
// If data is an object wrap the object into an array
|
101 |
+
if ($this->isJsonObject($data)) {
|
102 |
+
$data = array($data);
|
103 |
+
}
|
104 |
+
return $data;
|
105 |
+
}
|
106 |
+
// Second, check if the content contains special entries
|
107 |
+
if (isset($content['targetingsentencelines'])) {
|
108 |
+
return $content['targetingsentencelines'];
|
109 |
+
}
|
110 |
+
if (isset($content['adaccounts'])) {
|
111 |
+
return $content['adaccounts'];
|
112 |
+
}
|
113 |
+
if (isset($content['users'])) {
|
114 |
+
return $content['users'];
|
115 |
+
}
|
116 |
+
// Third, check if the content is an array of objects indexed by id
|
117 |
+
$is_id_indexed_array = \true;
|
118 |
+
$objects = array();
|
119 |
+
if (\is_array($content) && \count($content) >= 1) {
|
120 |
+
foreach ($content as $key => $value) {
|
121 |
+
if ($key === '__fb_trace_id__') {
|
122 |
+
continue;
|
123 |
+
}
|
124 |
+
if ($value !== null && $this->isJsonObject($value) && isset($value['id']) && $value['id'] !== null && $value['id'] === $key) {
|
125 |
+
$objects[] = $value;
|
126 |
+
} else {
|
127 |
+
$is_id_indexed_array = \false;
|
128 |
+
break;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$is_id_indexed_array = \false;
|
133 |
+
}
|
134 |
+
if ($is_id_indexed_array) {
|
135 |
+
return $objects;
|
136 |
+
}
|
137 |
+
throw new \InvalidArgumentException("Malformed response data");
|
138 |
+
}
|
139 |
+
private function isJsonObject($object)
|
140 |
+
{
|
141 |
+
if (!\is_array($object)) {
|
142 |
+
return \false;
|
143 |
+
}
|
144 |
+
// Consider an empty array as not object
|
145 |
+
if (empty($object)) {
|
146 |
+
return \false;
|
147 |
+
}
|
148 |
+
// A json object is represented by a map instead of a pure list
|
149 |
+
return \array_keys($object) !== \range(0, \count($object) - 1);
|
150 |
+
}
|
151 |
+
/**
|
152 |
+
* @param ResponseInterface $response
|
153 |
+
*/
|
154 |
+
protected function prependResponse(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
155 |
+
{
|
156 |
+
$this->response = $response;
|
157 |
+
$data = $this->assureResponseData($response);
|
158 |
+
if (empty($data)) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
$left_index = $this->indexLeft;
|
162 |
+
$count = \count($data);
|
163 |
+
$position = $count - 1;
|
164 |
+
for ($i = $left_index - 1; $i >= $left_index - $count; $i--) {
|
165 |
+
$this->objects[$i] = $this->createObject($data[$position--]);
|
166 |
+
--$this->indexLeft;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* @param ResponseInterface $response
|
171 |
+
*/
|
172 |
+
protected function appendResponse(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
173 |
+
{
|
174 |
+
$this->response = $response;
|
175 |
+
$data = $this->assureResponseData($response);
|
176 |
+
if (empty($data)) {
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
if ($this->indexRight === null) {
|
180 |
+
$this->indexLeft = 0;
|
181 |
+
$this->indexRight = -1;
|
182 |
+
$this->position = 0;
|
183 |
+
}
|
184 |
+
$this->indexRight += \count($data);
|
185 |
+
foreach ($data as $object_data) {
|
186 |
+
$this->objects[] = $this->createObject($object_data);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
/**
|
190 |
+
* @return bool
|
191 |
+
*/
|
192 |
+
public static function getDefaultUseImplicitFetch()
|
193 |
+
{
|
194 |
+
return static::$defaultUseImplicitFetch;
|
195 |
+
}
|
196 |
+
/**
|
197 |
+
* @param bool $use_implicit_fetch
|
198 |
+
*/
|
199 |
+
public static function setDefaultUseImplicitFetch($use_implicit_fetch)
|
200 |
+
{
|
201 |
+
static::$defaultUseImplicitFetch = $use_implicit_fetch;
|
202 |
+
}
|
203 |
+
/**
|
204 |
+
* @return bool
|
205 |
+
*/
|
206 |
+
public function getUseImplicitFetch()
|
207 |
+
{
|
208 |
+
return $this->useImplicitFetch !== null ? $this->useImplicitFetch : static::$defaultUseImplicitFetch;
|
209 |
+
}
|
210 |
+
/**
|
211 |
+
* @param bool $use_implicit_fetch
|
212 |
+
*/
|
213 |
+
public function setUseImplicitFetch($use_implicit_fetch)
|
214 |
+
{
|
215 |
+
$this->useImplicitFetch = $use_implicit_fetch;
|
216 |
+
}
|
217 |
+
/**
|
218 |
+
* @return string|null
|
219 |
+
*/
|
220 |
+
public function getBefore()
|
221 |
+
{
|
222 |
+
$content = $this->getLastResponse()->getContent();
|
223 |
+
return isset($content['paging']['cursors']['before']) ? $content['paging']['cursors']['before'] : null;
|
224 |
+
}
|
225 |
+
/**
|
226 |
+
* @return string|null
|
227 |
+
*/
|
228 |
+
public function getAfter()
|
229 |
+
{
|
230 |
+
$content = $this->getLastResponse()->getContent();
|
231 |
+
return isset($content['paging']['cursors']['after']) ? $content['paging']['cursors']['after'] : null;
|
232 |
+
}
|
233 |
+
/**
|
234 |
+
* @return RequestInterface
|
235 |
+
*/
|
236 |
+
protected function createUndirectionalizedRequest()
|
237 |
+
{
|
238 |
+
$request = $this->getLastResponse()->getRequest()->createClone();
|
239 |
+
$params = $request->getQueryParams();
|
240 |
+
if (isset($params['before'])) {
|
241 |
+
unset($params['before']);
|
242 |
+
}
|
243 |
+
if (isset($params['after'])) {
|
244 |
+
unset($params['after']);
|
245 |
+
}
|
246 |
+
return $request;
|
247 |
+
}
|
248 |
+
/**
|
249 |
+
* @return string|null
|
250 |
+
*/
|
251 |
+
public function getPrevious()
|
252 |
+
{
|
253 |
+
$content = $this->getLastResponse()->getContent();
|
254 |
+
if (isset($content['paging']['previous'])) {
|
255 |
+
return $content['paging']['previous'];
|
256 |
+
}
|
257 |
+
$before = $this->getBefore();
|
258 |
+
if ($before !== null) {
|
259 |
+
$request = $this->createUndirectionalizedRequest();
|
260 |
+
$request->getQueryParams()->offsetSet('before', $before);
|
261 |
+
return $request->getUrl();
|
262 |
+
}
|
263 |
+
return null;
|
264 |
+
}
|
265 |
+
/**
|
266 |
+
* @return string|null
|
267 |
+
*/
|
268 |
+
public function getNext()
|
269 |
+
{
|
270 |
+
$content = $this->getLastResponse()->getContent();
|
271 |
+
if (isset($content['paging']['next'])) {
|
272 |
+
return $content['paging']['next'];
|
273 |
+
}
|
274 |
+
$after = $this->getAfter();
|
275 |
+
if ($after !== null) {
|
276 |
+
$request = $this->createUndirectionalizedRequest();
|
277 |
+
$request->getQueryParams()->offsetSet('after', $after);
|
278 |
+
return $request->getUrl();
|
279 |
+
}
|
280 |
+
return null;
|
281 |
+
}
|
282 |
+
/**
|
283 |
+
* @param string $url
|
284 |
+
* @return RequestInterface
|
285 |
+
*/
|
286 |
+
protected function createRequestFromUrl($url)
|
287 |
+
{
|
288 |
+
$components = \parse_url($url);
|
289 |
+
$request = $this->getLastResponse()->getRequest()->createClone();
|
290 |
+
$request->setDomain($components['host']);
|
291 |
+
$query = isset($components['query']) ? \PixelCaffeine\Dependencies\FacebookAds\Http\Util::parseUrlQuery($components['query']) : array();
|
292 |
+
$request->getQueryParams()->enhance($query);
|
293 |
+
return $request;
|
294 |
+
}
|
295 |
+
/**
|
296 |
+
* @return RequestInterface|null
|
297 |
+
*/
|
298 |
+
public function createBeforeRequest()
|
299 |
+
{
|
300 |
+
$url = $this->getPrevious();
|
301 |
+
return $url !== null ? $this->createRequestFromUrl($url) : null;
|
302 |
+
}
|
303 |
+
/**
|
304 |
+
* @return RequestInterface|null
|
305 |
+
*/
|
306 |
+
public function createAfterRequest()
|
307 |
+
{
|
308 |
+
$url = $this->getNext();
|
309 |
+
return $url !== null ? $this->createRequestFromUrl($url) : null;
|
310 |
+
}
|
311 |
+
public function fetchBefore()
|
312 |
+
{
|
313 |
+
$request = $this->createBeforeRequest();
|
314 |
+
if (!$request) {
|
315 |
+
return;
|
316 |
+
}
|
317 |
+
$this->prependResponse($request->execute());
|
318 |
+
}
|
319 |
+
public function fetchAfter()
|
320 |
+
{
|
321 |
+
$request = $this->createAfterRequest();
|
322 |
+
if (!$request) {
|
323 |
+
return;
|
324 |
+
}
|
325 |
+
$this->appendResponse($request->execute());
|
326 |
+
}
|
327 |
+
/**
|
328 |
+
* @deprecated Use getArrayCopy()
|
329 |
+
* @return AbstractObject[]
|
330 |
+
*/
|
331 |
+
public function getObjects()
|
332 |
+
{
|
333 |
+
return $this->objects;
|
334 |
+
}
|
335 |
+
/**
|
336 |
+
* @param bool $ksort
|
337 |
+
* @return AbstractObject[]
|
338 |
+
*/
|
339 |
+
public function getArrayCopy($ksort = \false)
|
340 |
+
{
|
341 |
+
if ($ksort) {
|
342 |
+
// Sort the main array to improve best case performance in future
|
343 |
+
// invocations
|
344 |
+
\ksort($this->objects);
|
345 |
+
}
|
346 |
+
return $this->objects;
|
347 |
+
}
|
348 |
+
/**
|
349 |
+
* @deprecated Use getLastResponse()
|
350 |
+
* @return ResponseInterface
|
351 |
+
*/
|
352 |
+
public function getResponse()
|
353 |
+
{
|
354 |
+
return $this->response;
|
355 |
+
}
|
356 |
+
/**
|
357 |
+
* @return ResponseInterface
|
358 |
+
*/
|
359 |
+
public function getLastResponse()
|
360 |
+
{
|
361 |
+
return $this->response;
|
362 |
+
}
|
363 |
+
/**
|
364 |
+
* @return int
|
365 |
+
*/
|
366 |
+
public function getIndexLeft()
|
367 |
+
{
|
368 |
+
return $this->indexLeft;
|
369 |
+
}
|
370 |
+
/**
|
371 |
+
* @return int
|
372 |
+
*/
|
373 |
+
public function getIndexRight()
|
374 |
+
{
|
375 |
+
return $this->indexRight;
|
376 |
+
}
|
377 |
+
public function rewind()
|
378 |
+
{
|
379 |
+
$this->position = $this->indexLeft;
|
380 |
+
}
|
381 |
+
public function end()
|
382 |
+
{
|
383 |
+
$this->position = $this->indexRight;
|
384 |
+
}
|
385 |
+
/**
|
386 |
+
* @param int $position
|
387 |
+
*/
|
388 |
+
public function seekTo($position)
|
389 |
+
{
|
390 |
+
$position = \array_key_exists($position, $this->objects) ? $position : null;
|
391 |
+
$this->position = $position;
|
392 |
+
}
|
393 |
+
/**
|
394 |
+
* @return AbstractObject|bool
|
395 |
+
*/
|
396 |
+
public function current()
|
397 |
+
{
|
398 |
+
return isset($this->objects[$this->position]) ? $this->objects[$this->position] : \false;
|
399 |
+
}
|
400 |
+
/**
|
401 |
+
* @return int
|
402 |
+
*/
|
403 |
+
public function key()
|
404 |
+
{
|
405 |
+
return $this->position;
|
406 |
+
}
|
407 |
+
public function prev()
|
408 |
+
{
|
409 |
+
if ($this->position == $this->getIndexLeft()) {
|
410 |
+
if ($this->getUseImplicitFetch()) {
|
411 |
+
$this->fetchBefore();
|
412 |
+
if ($this->position == $this->getIndexLeft()) {
|
413 |
+
$this->position = null;
|
414 |
+
} else {
|
415 |
+
--$this->position;
|
416 |
+
}
|
417 |
+
} else {
|
418 |
+
$this->position = null;
|
419 |
+
}
|
420 |
+
} else {
|
421 |
+
--$this->position;
|
422 |
+
}
|
423 |
+
}
|
424 |
+
public function next()
|
425 |
+
{
|
426 |
+
if ($this->position == $this->getIndexRight()) {
|
427 |
+
if ($this->getUseImplicitFetch()) {
|
428 |
+
$this->fetchAfter();
|
429 |
+
if ($this->position == $this->getIndexRight()) {
|
430 |
+
$this->position = null;
|
431 |
+
} else {
|
432 |
+
++$this->position;
|
433 |
+
}
|
434 |
+
} else {
|
435 |
+
$this->position = null;
|
436 |
+
}
|
437 |
+
} else {
|
438 |
+
++$this->position;
|
439 |
+
}
|
440 |
+
}
|
441 |
+
/**
|
442 |
+
* @return bool
|
443 |
+
*/
|
444 |
+
public function valid()
|
445 |
+
{
|
446 |
+
return isset($this->objects[$this->position]);
|
447 |
+
}
|
448 |
+
/**
|
449 |
+
* @return int
|
450 |
+
*/
|
451 |
+
public function count()
|
452 |
+
{
|
453 |
+
return \count($this->objects);
|
454 |
+
}
|
455 |
+
/**
|
456 |
+
* @param mixed $offset
|
457 |
+
* @param mixed $value
|
458 |
+
*/
|
459 |
+
public function offsetSet($offset, $value)
|
460 |
+
{
|
461 |
+
if ($offset === null) {
|
462 |
+
$this->objects[] = $value;
|
463 |
+
} else {
|
464 |
+
$this->objects[$offset] = $value;
|
465 |
+
}
|
466 |
+
}
|
467 |
+
/**
|
468 |
+
* @param mixed $offset
|
469 |
+
* @return bool
|
470 |
+
*/
|
471 |
+
public function offsetExists($offset)
|
472 |
+
{
|
473 |
+
return isset($this->objects[$offset]);
|
474 |
+
}
|
475 |
+
/**
|
476 |
+
* @param mixed $offset
|
477 |
+
*/
|
478 |
+
public function offsetUnset($offset)
|
479 |
+
{
|
480 |
+
unset($this->objects[$offset]);
|
481 |
+
}
|
482 |
+
/**
|
483 |
+
* @param mixed $offset
|
484 |
+
* @return mixed
|
485 |
+
*/
|
486 |
+
public function offsetGet($offset)
|
487 |
+
{
|
488 |
+
return isset($this->objects[$offset]) ? $this->objects[$offset] : null;
|
489 |
+
}
|
490 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Enum/AbstractEnum.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Enum;
|
26 |
+
|
27 |
+
abstract class AbstractEnum implements \PixelCaffeine\Dependencies\FacebookAds\Enum\EnumInstanceInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var array|null
|
31 |
+
*/
|
32 |
+
protected $map = null;
|
33 |
+
/**
|
34 |
+
* @var array|null
|
35 |
+
*/
|
36 |
+
protected $names = null;
|
37 |
+
/**
|
38 |
+
* @var array|null
|
39 |
+
*/
|
40 |
+
protected $values = null;
|
41 |
+
/**
|
42 |
+
* @var array|null
|
43 |
+
*/
|
44 |
+
protected $valuesMap = null;
|
45 |
+
/**
|
46 |
+
* @var AbstractEnum[]
|
47 |
+
*/
|
48 |
+
protected static $instances = array();
|
49 |
+
/**
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
static function className()
|
53 |
+
{
|
54 |
+
return \get_called_class();
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* @return AbstractEnum
|
58 |
+
*/
|
59 |
+
public static function getInstance()
|
60 |
+
{
|
61 |
+
$fqn = \get_called_class();
|
62 |
+
if (!\array_key_exists($fqn, static::$instances)) {
|
63 |
+
static::$instances[$fqn] = new static();
|
64 |
+
}
|
65 |
+
return static::$instances[$fqn];
|
66 |
+
}
|
67 |
+
/**
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
public function getArrayCopy()
|
71 |
+
{
|
72 |
+
if ($this->map === null) {
|
73 |
+
$this->map = (new \ReflectionClass(\get_called_class()))->getConstants();
|
74 |
+
}
|
75 |
+
return $this->map;
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
public function getNames()
|
81 |
+
{
|
82 |
+
if ($this->names === null) {
|
83 |
+
$this->names = \array_keys($this->getArrayCopy());
|
84 |
+
}
|
85 |
+
return $this->names;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* @return array
|
89 |
+
*/
|
90 |
+
public function getValues()
|
91 |
+
{
|
92 |
+
if ($this->values === null) {
|
93 |
+
$this->values = \array_values($this->getArrayCopy());
|
94 |
+
}
|
95 |
+
return $this->values;
|
96 |
+
}
|
97 |
+
/**
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
public function getValuesMap()
|
101 |
+
{
|
102 |
+
if ($this->valuesMap === null) {
|
103 |
+
$this->valuesMap = \array_fill_keys($this->getValues(), null);
|
104 |
+
}
|
105 |
+
return $this->valuesMap;
|
106 |
+
}
|
107 |
+
/**
|
108 |
+
* @param string|int|float $name
|
109 |
+
* @return mixed
|
110 |
+
*/
|
111 |
+
public function getValueForName($name)
|
112 |
+
{
|
113 |
+
$copy = $this->getArrayCopy();
|
114 |
+
return \array_key_exists($name, $copy) ? $copy[$name] : null;
|
115 |
+
}
|
116 |
+
/**
|
117 |
+
* @param string|int|float $name
|
118 |
+
* @return mixed
|
119 |
+
* @throws \InvalidArgumentException
|
120 |
+
*/
|
121 |
+
public function assureValueForName($name)
|
122 |
+
{
|
123 |
+
$value = $this->getValueForName($name);
|
124 |
+
if ($value === null) {
|
125 |
+
throw new \InvalidArgumentException('Unknown name "' . $name . '" in ' . static::className());
|
126 |
+
}
|
127 |
+
return $value;
|
128 |
+
}
|
129 |
+
/**
|
130 |
+
* @param string|int|float $name
|
131 |
+
* @return bool
|
132 |
+
*/
|
133 |
+
public function isValid($name)
|
134 |
+
{
|
135 |
+
return \array_key_exists($name, $this->getArrayCopy());
|
136 |
+
}
|
137 |
+
/**
|
138 |
+
* @param string|int|float $name
|
139 |
+
* @throws \InvalidArgumentException
|
140 |
+
*/
|
141 |
+
public function assureIsValid($name)
|
142 |
+
{
|
143 |
+
if (!\array_key_exists($name, $this->getArrayCopy())) {
|
144 |
+
throw new \InvalidArgumentException('Unknown name "' . $name . '" in ' . static::className());
|
145 |
+
}
|
146 |
+
}
|
147 |
+
/**
|
148 |
+
* @param string|int|float $value
|
149 |
+
* @return bool
|
150 |
+
*/
|
151 |
+
public function isValidValue($value)
|
152 |
+
{
|
153 |
+
return \array_key_exists($value, $this->getValuesMap());
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* @param mixed $value
|
157 |
+
* @throws \InvalidArgumentException
|
158 |
+
*/
|
159 |
+
public function assureIsValidValue($value)
|
160 |
+
{
|
161 |
+
if (!$this->isValidValue($value)) {
|
162 |
+
throw new \InvalidArgumentException('"' . $value . '", not a valid value in ' . static::className());
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Enum/EmptyEnum.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,36 +22,36 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
}
|
56 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Enum;
|
26 |
|
27 |
+
class EmptyEnum extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function getArrayCopy()
|
33 |
+
{
|
34 |
+
return array();
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function getNames()
|
40 |
+
{
|
41 |
+
return array();
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
public function getValues()
|
47 |
+
{
|
48 |
+
return array();
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* @return array
|
52 |
+
*/
|
53 |
+
public function getValuesMap()
|
54 |
+
{
|
55 |
+
return array();
|
56 |
+
}
|
|
|
57 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Enum/EnumInstanceInterface.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Enum;
|
26 |
+
|
27 |
+
interface EnumInstanceInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return EnumInstanceInterface
|
31 |
+
*/
|
32 |
+
public static function getInstance();
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function getArrayCopy();
|
37 |
+
/**
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
public function getNames();
|
41 |
+
/**
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function getValues();
|
45 |
+
/**
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function getValuesMap();
|
49 |
+
/**
|
50 |
+
* @param string|int|float $name
|
51 |
+
* @return mixed
|
52 |
+
*/
|
53 |
+
public function getValueForName($name);
|
54 |
+
/**
|
55 |
+
* @param string|int|float $name
|
56 |
+
* @return mixed
|
57 |
+
* @throws \InvalidArgumentException
|
58 |
+
*/
|
59 |
+
public function assureValueForName($name);
|
60 |
+
/**
|
61 |
+
* @param string|int|float $name
|
62 |
+
* @return bool
|
63 |
+
*/
|
64 |
+
public function isValid($name);
|
65 |
+
/**
|
66 |
+
* @param string|int|float $name
|
67 |
+
* @return void
|
68 |
+
* @throws \InvalidArgumentException
|
69 |
+
*/
|
70 |
+
public function assureIsValid($name);
|
71 |
+
/**
|
72 |
+
* @param mixed $value
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function isValidValue($value);
|
76 |
+
/**
|
77 |
+
* @param mixed $value
|
78 |
+
* @throws \InvalidArgumentException
|
79 |
+
*/
|
80 |
+
public function assureIsValidValue($value);
|
81 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Exception/Exception.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class Exception extends \Exception {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Exception;
|
26 |
|
27 |
+
class Exception extends \Exception
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AbstractAdapter.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,36 +22,34 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
public function getCaBundlePath() {
|
54 |
-
return $this->getClient()->getCaBundlePath();
|
55 |
-
}
|
56 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
28 |
+
abstract class AbstractAdapter implements \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\AdapterInterface
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @var Client
|
32 |
+
*/
|
33 |
+
protected $client;
|
34 |
+
/**
|
35 |
+
* @param Client $client
|
36 |
+
*/
|
37 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client)
|
38 |
+
{
|
39 |
+
$this->client = $client;
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* @return Client
|
43 |
+
*/
|
44 |
+
public function getClient()
|
45 |
+
{
|
46 |
+
return $this->client;
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getCaBundlePath()
|
52 |
+
{
|
53 |
+
return $this->getClient()->getCaBundlePath();
|
54 |
+
}
|
|
|
|
|
|
|
55 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/AdapterInterface.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,44 +22,37 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Http\
|
28 |
-
use FacebookAds\Http\
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
public function setOpts(\ArrayObject $opts);
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @param RequestInterface $request
|
61 |
-
* @return ResponseInterface
|
62 |
-
*/
|
63 |
-
public function sendRequest(RequestInterface $request);
|
64 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
30 |
+
interface AdapterInterface
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @param Client $client
|
34 |
+
*/
|
35 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client);
|
36 |
+
/**
|
37 |
+
* @return Client
|
38 |
+
*/
|
39 |
+
public function getClient();
|
40 |
+
/**
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getCaBundlePath();
|
44 |
+
/**
|
45 |
+
* @return \ArrayObject
|
46 |
+
*/
|
47 |
+
public function getOpts();
|
48 |
+
/**
|
49 |
+
* @param \ArrayObject $opts
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
public function setOpts(\ArrayObject $opts);
|
53 |
+
/**
|
54 |
+
* @param RequestInterface $request
|
55 |
+
* @return ResponseInterface
|
56 |
+
*/
|
57 |
+
public function sendRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/AbstractCurl.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl;
|
26 |
+
|
27 |
+
abstract class AbstractCurl implements \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\CurlInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var resource
|
31 |
+
*/
|
32 |
+
protected $handle;
|
33 |
+
/**
|
34 |
+
* @throws \RuntimeException
|
35 |
+
*/
|
36 |
+
public function __construct()
|
37 |
+
{
|
38 |
+
if (!\extension_loaded('curl')) {
|
39 |
+
throw new \RuntimeException("Extension curl not loaded");
|
40 |
+
}
|
41 |
+
}
|
42 |
+
public function __clone()
|
43 |
+
{
|
44 |
+
$this->handle = \curl_copy_handle($this->handle);
|
45 |
+
}
|
46 |
+
public function __destruct()
|
47 |
+
{
|
48 |
+
if (\is_resource($this->handle)) {
|
49 |
+
\curl_close($this->handle);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* @return CurlInterface
|
54 |
+
*/
|
55 |
+
public static function createOptimalVersion()
|
56 |
+
{
|
57 |
+
if (\version_compare(\PHP_VERSION, '5.5.0') >= 0) {
|
58 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\Curl55();
|
59 |
+
} else {
|
60 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\Curl();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* @return resource
|
65 |
+
*/
|
66 |
+
public function getHandle()
|
67 |
+
{
|
68 |
+
return $this->handle;
|
69 |
+
}
|
70 |
+
/**
|
71 |
+
* @return int
|
72 |
+
*/
|
73 |
+
public function errno()
|
74 |
+
{
|
75 |
+
return \curl_errno($this->handle);
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function error()
|
81 |
+
{
|
82 |
+
return \curl_error($this->handle);
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* @return mixed
|
86 |
+
*/
|
87 |
+
public function exec()
|
88 |
+
{
|
89 |
+
return \curl_exec($this->handle);
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* @param int $opt
|
93 |
+
* @return mixed
|
94 |
+
*/
|
95 |
+
public function getInfo($opt = 0)
|
96 |
+
{
|
97 |
+
return \curl_getinfo($this->handle, $opt);
|
98 |
+
}
|
99 |
+
/**
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function init()
|
103 |
+
{
|
104 |
+
$this->handle = $this->handle ?: \curl_init();
|
105 |
+
}
|
106 |
+
/**
|
107 |
+
* @param array $opts
|
108 |
+
*/
|
109 |
+
public function setoptArray(array $opts)
|
110 |
+
{
|
111 |
+
\curl_setopt_array($this->handle, $opts);
|
112 |
+
}
|
113 |
+
/**
|
114 |
+
* @param int $option
|
115 |
+
* @param mixed $value
|
116 |
+
* @return bool
|
117 |
+
*/
|
118 |
+
public function setopt($option, $value)
|
119 |
+
{
|
120 |
+
return \curl_setopt($this->handle, $option, $value);
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* @param int $age
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public static function version($age)
|
127 |
+
{
|
128 |
+
return \curl_version($age);
|
129 |
+
}
|
130 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter;
|
28 |
+
class Curl extends \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\AbstractCurl
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @throws \RuntimeException
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
if (\version_compare(\PHP_VERSION, '5.5.0') >= 0) {
|
37 |
+
throw new \RuntimeException("Unsupported Curl version");
|
38 |
+
}
|
39 |
+
}
|
40 |
+
/**
|
41 |
+
* @param string $string
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function escape($string)
|
45 |
+
{
|
46 |
+
return \rawurlencode($string);
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* @param int $bitmask
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
public function pause($bitmask)
|
53 |
+
{
|
54 |
+
return 0;
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* FIXME should introduce v2.10 breaking change:
|
58 |
+
* implement abstract support for FileParameter in AdapterInterface
|
59 |
+
*
|
60 |
+
* @param string|FileParameter $filepath
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function preparePostFileField($filepath)
|
64 |
+
{
|
65 |
+
$mime_type = $name = '';
|
66 |
+
if ($filepath instanceof \PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter) {
|
67 |
+
$mime_type = $filepath->getMimeType() !== null ? \sprintf(';type=%s', $filepath->getMimeType()) : '';
|
68 |
+
$name = $filepath->getName() !== null ? \sprintf(';filename=%s', $filepath->getName()) : '';
|
69 |
+
$filepath = $filepath->getPath();
|
70 |
+
}
|
71 |
+
return \sprintf('@%s%s%s', $filepath, $mime_type, $name);
|
72 |
+
}
|
73 |
+
/**
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
public function reset()
|
77 |
+
{
|
78 |
+
$this->handle && \curl_close($this->handle);
|
79 |
+
$this->handle = \curl_init();
|
80 |
+
}
|
81 |
+
/**
|
82 |
+
* @param int $errornum
|
83 |
+
* @return NULL|string
|
84 |
+
*/
|
85 |
+
public static function strerror($errornum)
|
86 |
+
{
|
87 |
+
return \curl_strerror($errornum);
|
88 |
+
}
|
89 |
+
/**
|
90 |
+
* @param string $string
|
91 |
+
* @return bool|string
|
92 |
+
*/
|
93 |
+
public function unescape($string)
|
94 |
+
{
|
95 |
+
return \curl_unescape($this->handle, $string);
|
96 |
+
}
|
97 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/Curl55.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter;
|
28 |
+
class Curl55 extends \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\AbstractCurl
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @throws \RuntimeException
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
if (\version_compare(\PHP_VERSION, '5.5.0') < 0) {
|
37 |
+
throw new \RuntimeException("Unsupported Curl version");
|
38 |
+
}
|
39 |
+
}
|
40 |
+
/**
|
41 |
+
* @param string $string
|
42 |
+
* @return bool|string
|
43 |
+
*/
|
44 |
+
public function escape($string)
|
45 |
+
{
|
46 |
+
return \curl_escape($this->handle, $string);
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* @param int $bitmask
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
public function pause($bitmask)
|
53 |
+
{
|
54 |
+
return \curl_pause($this->handle, $bitmask);
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* FIXME should introduce v2.10 breaking change:
|
58 |
+
* implement abstract support for FileParameter in AdapterInterface
|
59 |
+
*
|
60 |
+
* @param string|FileParameter $filepath
|
61 |
+
* @return \CURLFile
|
62 |
+
*/
|
63 |
+
public function preparePostFileField($filepath)
|
64 |
+
{
|
65 |
+
$mime_type = $name = '';
|
66 |
+
// can't be null in HHVM
|
67 |
+
if ($filepath instanceof \PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter) {
|
68 |
+
$mime_type = $filepath->getMimeType() ?: '';
|
69 |
+
$name = $filepath->getName() ?: '';
|
70 |
+
$filepath = $filepath->getPath();
|
71 |
+
}
|
72 |
+
return new \CURLFile($filepath, $mime_type, $name);
|
73 |
+
}
|
74 |
+
/**
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function reset()
|
78 |
+
{
|
79 |
+
$this->handle && \curl_reset($this->handle);
|
80 |
+
}
|
81 |
+
/**
|
82 |
+
* @param int $errornum
|
83 |
+
* @return NULL|string
|
84 |
+
*/
|
85 |
+
public static function strerror($errornum)
|
86 |
+
{
|
87 |
+
return \curl_strerror($errornum);
|
88 |
+
}
|
89 |
+
/**
|
90 |
+
* @param string $string
|
91 |
+
* @return bool|string
|
92 |
+
*/
|
93 |
+
public function unescape($string)
|
94 |
+
{
|
95 |
+
return \curl_unescape($this->handle, $string);
|
96 |
+
}
|
97 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/Curl/CurlInterface.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl;
|
26 |
+
|
27 |
+
interface CurlInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return resource
|
31 |
+
*/
|
32 |
+
public function getHandle();
|
33 |
+
/**
|
34 |
+
* @return int
|
35 |
+
*/
|
36 |
+
public function errno();
|
37 |
+
/**
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function error();
|
41 |
+
/**
|
42 |
+
* @param string $string
|
43 |
+
* @return bool|string
|
44 |
+
*/
|
45 |
+
public function escape($string);
|
46 |
+
/**
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
public function exec();
|
50 |
+
/**
|
51 |
+
* @param int $opt
|
52 |
+
* @return mixed
|
53 |
+
*/
|
54 |
+
public function getInfo($opt = 0);
|
55 |
+
/**
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
public function init();
|
59 |
+
/**
|
60 |
+
* @param int $bitmask
|
61 |
+
* @return int
|
62 |
+
*/
|
63 |
+
public function pause($bitmask);
|
64 |
+
/**
|
65 |
+
* @param $filepath
|
66 |
+
* @return string|\CurlFile
|
67 |
+
*/
|
68 |
+
public function preparePostFileField($filepath);
|
69 |
+
/**
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
public function reset();
|
73 |
+
/**
|
74 |
+
* @param array $opts
|
75 |
+
*/
|
76 |
+
public function setoptArray(array $opts);
|
77 |
+
/**
|
78 |
+
* @param int $option
|
79 |
+
* @param mixed $value
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public function setopt($option, $value);
|
83 |
+
/**
|
84 |
+
* @param $string
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function unescape($string);
|
88 |
+
/**
|
89 |
+
* @param int $age
|
90 |
+
* @return array
|
91 |
+
*/
|
92 |
+
public static function version($age);
|
93 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Adapter/CurlAdapter.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Adapter;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Exception\Exception;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\AbstractCurl;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\Curl;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\CurlInterface;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
32 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Headers;
|
33 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
34 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
35 |
+
class CurlAdapter extends \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\AbstractAdapter
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* @var CurlInterface
|
39 |
+
*/
|
40 |
+
protected $curl;
|
41 |
+
/**
|
42 |
+
* @var \ArrayObject
|
43 |
+
*/
|
44 |
+
protected $opts;
|
45 |
+
/**
|
46 |
+
* @param Client $client
|
47 |
+
* @param CurlInterface $curl
|
48 |
+
*/
|
49 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client, \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\CurlInterface $curl = null)
|
50 |
+
{
|
51 |
+
parent::__construct($client);
|
52 |
+
$this->curl = $curl ?: \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\Curl\AbstractCurl::createOptimalVersion();
|
53 |
+
$this->curl->init();
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* @return Curl
|
57 |
+
*/
|
58 |
+
public function getCurl()
|
59 |
+
{
|
60 |
+
return $this->curl;
|
61 |
+
}
|
62 |
+
/**
|
63 |
+
* @return \ArrayObject
|
64 |
+
*/
|
65 |
+
public function getOpts()
|
66 |
+
{
|
67 |
+
if ($this->opts === null) {
|
68 |
+
$this->opts = new \ArrayObject(array(\CURLOPT_CONNECTTIMEOUT => 10, \CURLOPT_TIMEOUT => 60, \CURLOPT_RETURNTRANSFER => \true, \CURLOPT_HEADER => \true, \CURLOPT_CAINFO => $this->getCaBundlePath()));
|
69 |
+
}
|
70 |
+
return $this->opts;
|
71 |
+
}
|
72 |
+
/**
|
73 |
+
* @param \ArrayObject $opts
|
74 |
+
*/
|
75 |
+
public function setOpts(\ArrayObject $opts)
|
76 |
+
{
|
77 |
+
$this->opts = $opts;
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
* @return int
|
81 |
+
*/
|
82 |
+
protected function getheaderSize()
|
83 |
+
{
|
84 |
+
return $this->getCurl()->getInfo(\CURLINFO_HEADER_SIZE);
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* Extracts the headers and the body into a two-part array
|
88 |
+
* @param string $raw_response
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
protected function extractResponseHeadersAndBody($raw_response)
|
92 |
+
{
|
93 |
+
$header_size = $this->getheaderSize();
|
94 |
+
$raw_headers = \mb_substr($raw_response, 0, $header_size);
|
95 |
+
$raw_body = \mb_substr($raw_response, $header_size);
|
96 |
+
return array(\trim($raw_headers), \trim($raw_body));
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* @param Headers $headers
|
100 |
+
* @param string $raw_headers
|
101 |
+
*/
|
102 |
+
protected function parseHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers, $raw_headers)
|
103 |
+
{
|
104 |
+
$raw_headers = \str_replace("\r\n", "\n", $raw_headers);
|
105 |
+
// There will be multiple headers if a 301 was followed
|
106 |
+
// or a proxy was followed, etc
|
107 |
+
$header_collection = \explode("\n\n", \trim($raw_headers));
|
108 |
+
// We just want the last response (at the end)
|
109 |
+
$raw_headers = \array_pop($header_collection);
|
110 |
+
$header_components = \explode("\n", $raw_headers);
|
111 |
+
foreach ($header_components as $line) {
|
112 |
+
if (\strpos($line, ': ') === \false) {
|
113 |
+
$headers['http_code'] = $line;
|
114 |
+
} else {
|
115 |
+
list($key, $value) = \explode(': ', $line, 2);
|
116 |
+
$headers[$key] = $value;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
/**
|
121 |
+
* @param RequestInterface $request
|
122 |
+
* @return ResponseInterface
|
123 |
+
* @throws Exception
|
124 |
+
*/
|
125 |
+
public function sendRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request)
|
126 |
+
{
|
127 |
+
$response = $this->getClient()->createResponse();
|
128 |
+
$this->getCurl()->reset();
|
129 |
+
$curlopts = array(\CURLOPT_URL => $request->getUrl());
|
130 |
+
$method = $request->getMethod();
|
131 |
+
if ($method !== \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET && $method !== \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST) {
|
132 |
+
$curlopts[\CURLOPT_CUSTOMREQUEST] = $method;
|
133 |
+
}
|
134 |
+
$curlopts = $this->getOpts()->getArrayCopy() + $curlopts;
|
135 |
+
if ($request->getHeaders()->count()) {
|
136 |
+
$headers = array();
|
137 |
+
foreach ($request->getHeaders() as $header => $value) {
|
138 |
+
$headers[] = "{$header}: {$value}";
|
139 |
+
}
|
140 |
+
$curlopts[\CURLOPT_HTTPHEADER] = $headers;
|
141 |
+
}
|
142 |
+
$postfields = array();
|
143 |
+
if ($method === \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST && $request->getFileParams()->count()) {
|
144 |
+
$postfields = \array_merge($postfields, \array_map(array($this->getCurl(), 'preparePostFileField'), $request->getFileParams()->getArrayCopy()));
|
145 |
+
}
|
146 |
+
if ($method !== \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET && $request->getBodyParams()->count()) {
|
147 |
+
$postfields = \array_merge($postfields, $request->getBodyParams()->export());
|
148 |
+
}
|
149 |
+
if (!empty($postfields)) {
|
150 |
+
$curlopts[\CURLOPT_POSTFIELDS] = $postfields;
|
151 |
+
}
|
152 |
+
$this->getCurl()->setoptArray($curlopts);
|
153 |
+
$raw_response = $this->getCurl()->exec();
|
154 |
+
$status_code = $this->getCurl()->getInfo(\CURLINFO_HTTP_CODE);
|
155 |
+
$curl_errno = $this->getCurl()->errno();
|
156 |
+
$curl_error = $curl_errno ? $this->getCurl()->error() : null;
|
157 |
+
$response_parts = $this->extractResponseHeadersAndBody($raw_response);
|
158 |
+
$response->setStatusCode($status_code);
|
159 |
+
$this->parseHeaders($response->getHeaders(), $response_parts[0]);
|
160 |
+
$response->setBody($response_parts[1]);
|
161 |
+
if ($curl_errno) {
|
162 |
+
throw new \PixelCaffeine\Dependencies\FacebookAds\Exception\Exception($curl_error, $curl_errno);
|
163 |
+
}
|
164 |
+
return $response;
|
165 |
+
}
|
166 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Client.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiConfig;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\AdapterInterface;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\CurlAdapter;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Exception\EmptyResponseException;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException;
|
32 |
+
class Client
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
const DEFAULT_GRAPH_BASE_DOMAIN = 'facebook.com';
|
38 |
+
/**
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
const DEFAULT_LAST_LEVEL_DOMAIN = 'graph';
|
42 |
+
/**
|
43 |
+
* @var RequestInterface
|
44 |
+
*/
|
45 |
+
protected $requestPrototype;
|
46 |
+
/**
|
47 |
+
* @var ResponseInterface
|
48 |
+
*/
|
49 |
+
protected $responsePrototype;
|
50 |
+
/**
|
51 |
+
* @var Headers
|
52 |
+
*/
|
53 |
+
protected $defaultRequestHeaders;
|
54 |
+
/**
|
55 |
+
* @var AdapterInterface
|
56 |
+
*/
|
57 |
+
protected $adapter;
|
58 |
+
/**
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $caBundlePath;
|
62 |
+
/**
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
protected $defaultGraphBaseDomain = self::DEFAULT_GRAPH_BASE_DOMAIN;
|
66 |
+
/**
|
67 |
+
* @return RequestInterface
|
68 |
+
*/
|
69 |
+
public function getRequestPrototype()
|
70 |
+
{
|
71 |
+
if ($this->requestPrototype === null) {
|
72 |
+
$this->requestPrototype = new \PixelCaffeine\Dependencies\FacebookAds\Http\Request($this);
|
73 |
+
}
|
74 |
+
return $this->requestPrototype;
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* @param RequestInterface $prototype
|
78 |
+
*/
|
79 |
+
public function setRequestPrototype(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $prototype)
|
80 |
+
{
|
81 |
+
$this->requestPrototype = $prototype;
|
82 |
+
}
|
83 |
+
/**
|
84 |
+
* @return RequestInterface
|
85 |
+
*/
|
86 |
+
public function createRequest()
|
87 |
+
{
|
88 |
+
return $this->getRequestPrototype()->createClone();
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* @return ResponseInterface
|
92 |
+
*/
|
93 |
+
public function getResponsePrototype()
|
94 |
+
{
|
95 |
+
if ($this->responsePrototype === null) {
|
96 |
+
$this->responsePrototype = new \PixelCaffeine\Dependencies\FacebookAds\Http\Response();
|
97 |
+
}
|
98 |
+
return $this->responsePrototype;
|
99 |
+
}
|
100 |
+
/**
|
101 |
+
* @param ResponseInterface $prototype
|
102 |
+
*/
|
103 |
+
public function setResponsePrototype(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $prototype)
|
104 |
+
{
|
105 |
+
$this->responsePrototype = $prototype;
|
106 |
+
}
|
107 |
+
/**
|
108 |
+
* @return ResponseInterface
|
109 |
+
*/
|
110 |
+
public function createResponse()
|
111 |
+
{
|
112 |
+
return clone $this->getResponsePrototype();
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* @return Headers
|
116 |
+
*/
|
117 |
+
public function getDefaultRequestHeaderds()
|
118 |
+
{
|
119 |
+
if ($this->defaultRequestHeaders === null) {
|
120 |
+
$this->defaultRequestHeaders = new \PixelCaffeine\Dependencies\FacebookAds\Http\Headers(array('User-Agent' => 'fbbizsdk-php-v' . \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::SDKVersion, 'Accept-Encoding' => '*'));
|
121 |
+
}
|
122 |
+
return $this->defaultRequestHeaders;
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* @param Headers $headers
|
126 |
+
*/
|
127 |
+
public function setDefaultRequestHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers)
|
128 |
+
{
|
129 |
+
$this->defaultRequestHeaders = $headers;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* @return string
|
133 |
+
*/
|
134 |
+
public function getDefaultGraphBaseDomain()
|
135 |
+
{
|
136 |
+
return $this->defaultGraphBaseDomain;
|
137 |
+
}
|
138 |
+
/**
|
139 |
+
* @param string $domain
|
140 |
+
*/
|
141 |
+
public function setDefaultGraphBaseDomain($domain)
|
142 |
+
{
|
143 |
+
$this->defaultGraphBaseDomain = $domain;
|
144 |
+
}
|
145 |
+
/**
|
146 |
+
* @return AdapterInterface
|
147 |
+
*/
|
148 |
+
public function getAdapter()
|
149 |
+
{
|
150 |
+
if ($this->adapter === null) {
|
151 |
+
$this->adapter = new \PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\CurlAdapter($this);
|
152 |
+
}
|
153 |
+
return $this->adapter;
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* @param AdapterInterface $adapter
|
157 |
+
*/
|
158 |
+
public function setAdapter(\PixelCaffeine\Dependencies\FacebookAds\Http\Adapter\AdapterInterface $adapter)
|
159 |
+
{
|
160 |
+
$this->adapter = $adapter;
|
161 |
+
}
|
162 |
+
/**
|
163 |
+
* @return string
|
164 |
+
*/
|
165 |
+
public function getCaBundlePath()
|
166 |
+
{
|
167 |
+
if ($this->caBundlePath === null) {
|
168 |
+
$this->caBundlePath = __DIR__ . \DIRECTORY_SEPARATOR . \str_repeat('..' . \DIRECTORY_SEPARATOR, 3) . 'fb_ca_chain_bundle.crt';
|
169 |
+
}
|
170 |
+
return $this->caBundlePath;
|
171 |
+
}
|
172 |
+
/**
|
173 |
+
* @param string $path
|
174 |
+
*/
|
175 |
+
public function setCaBundlePath($path)
|
176 |
+
{
|
177 |
+
$this->caBundlePath = $path;
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* @param RequestInterface $request
|
181 |
+
* @return ResponseInterface
|
182 |
+
* @throws RequestException
|
183 |
+
*/
|
184 |
+
public function sendRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request)
|
185 |
+
{
|
186 |
+
$response = $this->getAdapter()->sendRequest($request);
|
187 |
+
$response->setRequest($request);
|
188 |
+
$response_content = $response->getContent();
|
189 |
+
if ($response_content === null) {
|
190 |
+
throw new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\EmptyResponseException($response);
|
191 |
+
}
|
192 |
+
if (\is_array($response_content) && \array_key_exists('error', $response_content)) {
|
193 |
+
throw \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException::create($response);
|
194 |
+
}
|
195 |
+
return $response;
|
196 |
+
}
|
197 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/AuthorizationException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class AuthorizationException extends RequestException {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
class AuthorizationException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ClientException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class ClientException extends RequestException {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
class ClientException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/EmptyResponseException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,22 +22,18 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
'message' => 'Empty Response',
|
38 |
-
));
|
39 |
-
$response->setBody(json_encode($content));
|
40 |
-
parent::__construct($response);
|
41 |
-
}
|
42 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
28 |
+
class EmptyResponseException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @param ResponseInterface $response
|
32 |
+
*/
|
33 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
34 |
+
{
|
35 |
+
$content = array('error' => array('message' => 'Empty Response'));
|
36 |
+
$response->setBody(\json_encode($content));
|
37 |
+
parent::__construct($response);
|
38 |
+
}
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/PermissionException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class PermissionException extends RequestException {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
class PermissionException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
28 |
+
{
|
|
|
|
|
29 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Exception\Exception;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
29 |
+
class RequestException extends \PixelCaffeine\Dependencies\FacebookAds\Exception\Exception
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* @var ResponseInterface|null
|
33 |
+
*/
|
34 |
+
protected $response;
|
35 |
+
/**
|
36 |
+
* @var Headers
|
37 |
+
*/
|
38 |
+
protected $headers;
|
39 |
+
/**
|
40 |
+
* @var int|null
|
41 |
+
*/
|
42 |
+
protected $errorCode;
|
43 |
+
/**
|
44 |
+
* @var int|null
|
45 |
+
*/
|
46 |
+
protected $errorSubcode;
|
47 |
+
/**
|
48 |
+
* @var string|null
|
49 |
+
*/
|
50 |
+
protected $errorMessage;
|
51 |
+
/**
|
52 |
+
* @var string|null
|
53 |
+
*/
|
54 |
+
protected $errorUserTitle;
|
55 |
+
/**
|
56 |
+
* @var string|null
|
57 |
+
*/
|
58 |
+
protected $errorUserMessage;
|
59 |
+
/**
|
60 |
+
* @var int|null
|
61 |
+
*/
|
62 |
+
protected $errorType;
|
63 |
+
/**
|
64 |
+
* @var array|null
|
65 |
+
*/
|
66 |
+
protected $errorBlameFieldSpecs;
|
67 |
+
/**
|
68 |
+
* @var string|null
|
69 |
+
*/
|
70 |
+
protected $facebookTraceId;
|
71 |
+
/**
|
72 |
+
* @param ResponseInterface $response
|
73 |
+
*/
|
74 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
75 |
+
{
|
76 |
+
$this->headers = $response->getHeaders();
|
77 |
+
$this->response = $response;
|
78 |
+
$error_data = static::getErrorData($response);
|
79 |
+
parent::__construct($error_data['message'], $error_data['code']);
|
80 |
+
$this->errorSubcode = $error_data['error_subcode'];
|
81 |
+
$this->errorUserTitle = $error_data['error_user_title'];
|
82 |
+
$this->errorUserMessage = $error_data['error_user_msg'];
|
83 |
+
$this->errorBlameFieldSpecs = $error_data['error_blame_field_specs'];
|
84 |
+
$this->facebookTraceId = $error_data['fbtrace_id'];
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* @return ResponseInterface|null
|
88 |
+
*/
|
89 |
+
public function getResponse()
|
90 |
+
{
|
91 |
+
return $this->response;
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* @param array|string $array
|
95 |
+
* @param string|int $key
|
96 |
+
* @param mixed $default
|
97 |
+
* @return mixed
|
98 |
+
*/
|
99 |
+
protected static function idx($array, $key, $default = null)
|
100 |
+
{
|
101 |
+
if (\is_string($array)) {
|
102 |
+
$array = \json_decode($array, \true);
|
103 |
+
}
|
104 |
+
if (\is_null($array)) {
|
105 |
+
return null;
|
106 |
+
}
|
107 |
+
return \array_key_exists($key, $array) ? $array[$key] : $default;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* @param ResponseInterface $response
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
protected static function getErrorData(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
114 |
+
{
|
115 |
+
$response_data = $response->getContent();
|
116 |
+
if (\is_null($response_data)) {
|
117 |
+
$response_data = array();
|
118 |
+
}
|
119 |
+
$error_data = static::idx($response_data, 'error', array());
|
120 |
+
if (\is_string(static::idx($error_data, 'error_data'))) {
|
121 |
+
$error_data["error_data"] = \json_decode(\stripslashes(static::idx($error_data, 'error_data')), \true);
|
122 |
+
}
|
123 |
+
if (\is_null(static::idx($error_data, 'error_data'))) {
|
124 |
+
$error_data["error_data"] = array();
|
125 |
+
}
|
126 |
+
return array('code' => static::idx($error_data, 'code', static::idx($response_data, 'code')), 'error_subcode' => static::idx($error_data, 'error_subcode'), 'message' => static::idx($error_data, 'message'), 'error_user_title' => static::idx($error_data, 'error_user_title'), 'error_user_msg' => static::idx($error_data, 'error_user_msg'), 'error_blame_field_specs' => static::idx(static::idx($error_data, 'error_data', array()), 'blame_field_specs'), 'fbtrace_id' => static::idx($error_data, 'fbtrace_id'), 'type' => static::idx($error_data, 'type'));
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* Process an error payload from the Graph API and return the appropriate
|
130 |
+
* exception subclass.
|
131 |
+
* @param ResponseInterface $response
|
132 |
+
* @return RequestException
|
133 |
+
*/
|
134 |
+
public static function create(\PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response)
|
135 |
+
{
|
136 |
+
$error_data = static::getErrorData($response);
|
137 |
+
if (\in_array($error_data['error_subcode'], array(458, 459, 460, 463, 464, 467)) || \in_array($error_data['code'], array(100, 102, 190)) || $error_data['type'] === 'OAuthException') {
|
138 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\AuthorizationException($response);
|
139 |
+
} elseif (\in_array($error_data['code'], array(1, 2))) {
|
140 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\ServerException($response);
|
141 |
+
} elseif (\in_array($error_data['code'], array(4, 17, 341))) {
|
142 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\ThrottleException($response);
|
143 |
+
} elseif ($error_data['code'] == 506) {
|
144 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\ClientException($response);
|
145 |
+
} elseif ($error_data['code'] == 10 || $error_data['code'] >= 200 && $error_data['code'] <= 299) {
|
146 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\PermissionException($response);
|
147 |
+
} else {
|
148 |
+
return new self($response);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
/**
|
152 |
+
* @return int
|
153 |
+
*/
|
154 |
+
public function getHttpStatusCode()
|
155 |
+
{
|
156 |
+
return $this->response->getStatusCode();
|
157 |
+
}
|
158 |
+
/**
|
159 |
+
* @return int|null
|
160 |
+
*/
|
161 |
+
public function getErrorSubcode()
|
162 |
+
{
|
163 |
+
return $this->errorSubcode;
|
164 |
+
}
|
165 |
+
/**
|
166 |
+
* @return string|null
|
167 |
+
*/
|
168 |
+
public function getErrorUserTitle()
|
169 |
+
{
|
170 |
+
return $this->errorUserTitle;
|
171 |
+
}
|
172 |
+
/**
|
173 |
+
* @return string|null
|
174 |
+
*/
|
175 |
+
public function getErrorUserMessage()
|
176 |
+
{
|
177 |
+
return $this->errorUserMessage;
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* @return array|null
|
181 |
+
*/
|
182 |
+
public function getErrorBlameFieldSpecs()
|
183 |
+
{
|
184 |
+
return $this->errorBlameFieldSpecs;
|
185 |
+
}
|
186 |
+
/**
|
187 |
+
* @return string|null
|
188 |
+
*/
|
189 |
+
public function getFacebookTraceId()
|
190 |
+
{
|
191 |
+
return $this->facebookTraceId;
|
192 |
+
}
|
193 |
+
/**
|
194 |
+
* @return bool
|
195 |
+
*/
|
196 |
+
public function isTransient()
|
197 |
+
{
|
198 |
+
if ($this->getResponse() !== null) {
|
199 |
+
return \false;
|
200 |
+
}
|
201 |
+
$body = $this->getResponse()->getBody();
|
202 |
+
return \array_key_exists('error', $body) && \array_key_exists('is_transient', $body['error']) && $body['error']['is_transient'];
|
203 |
+
}
|
204 |
+
/**
|
205 |
+
* @return Headers
|
206 |
+
*/
|
207 |
+
public function getHeaders()
|
208 |
+
{
|
209 |
+
return $this->headers;
|
210 |
+
}
|
211 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ServerException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class ServerException extends RequestException {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
class ServerException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Exception/ThrottleException.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class ThrottleException extends RequestException {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http\Exception;
|
26 |
|
27 |
+
class ThrottleException extends \PixelCaffeine\Dependencies\FacebookAds\Http\Exception\RequestException
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/FileParameter.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,69 +22,66 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
public function setName($name) {
|
86 |
-
$this->name = $name;
|
87 |
-
return $this;
|
88 |
-
}
|
89 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
|
27 |
+
class FileParameter
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $path;
|
33 |
+
/**
|
34 |
+
* @var string|null
|
35 |
+
*/
|
36 |
+
protected $mimeType;
|
37 |
+
/**
|
38 |
+
* @var string|null
|
39 |
+
*/
|
40 |
+
protected $name;
|
41 |
+
/**
|
42 |
+
* @param string $path
|
43 |
+
*/
|
44 |
+
public function __construct($path)
|
45 |
+
{
|
46 |
+
$this->path = $path;
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getPath()
|
52 |
+
{
|
53 |
+
return $this->path;
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* @return null|string
|
57 |
+
*/
|
58 |
+
public function getMimeType()
|
59 |
+
{
|
60 |
+
return $this->mimeType;
|
61 |
+
}
|
62 |
+
/**
|
63 |
+
* @param null|string $mime_type
|
64 |
+
* @return $this
|
65 |
+
*/
|
66 |
+
public function setMimeType($mime_type)
|
67 |
+
{
|
68 |
+
$this->mimeType = $mime_type;
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
/**
|
72 |
+
* @return null|string
|
73 |
+
*/
|
74 |
+
public function getName()
|
75 |
+
{
|
76 |
+
return $this->name;
|
77 |
+
}
|
78 |
+
/**
|
79 |
+
* @param null|string $name
|
80 |
+
* @return $this
|
81 |
+
*/
|
82 |
+
public function setName($name)
|
83 |
+
{
|
84 |
+
$this->name = $name;
|
85 |
+
return $this;
|
86 |
+
}
|
|
|
|
|
|
|
|
|
87 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Headers.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,9 +22,8 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
class Headers extends \ArrayObject {
|
28 |
-
|
29 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
|
27 |
+
class Headers extends \ArrayObject
|
28 |
+
{
|
|
|
|
|
29 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Parameters.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,39 +22,36 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
}
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
: $this->exportNonScalar($value);
|
55 |
}
|
56 |
-
|
57 |
-
return $data;
|
58 |
-
}
|
59 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
|
27 |
+
class Parameters extends \ArrayObject
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @param array $data
|
31 |
+
*/
|
32 |
+
public function enhance(array $data)
|
33 |
+
{
|
34 |
+
foreach ($data as $key => $value) {
|
35 |
+
$this[$key] = $value;
|
36 |
+
}
|
37 |
}
|
38 |
+
/**
|
39 |
+
* @param mixed $value
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
protected function exportNonScalar($value)
|
43 |
+
{
|
44 |
+
return \json_encode($value);
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
public function export()
|
50 |
+
{
|
51 |
+
$data = array();
|
52 |
+
foreach ($this as $key => $value) {
|
53 |
+
$data[$key] = \is_null($value) || \is_scalar($value) ? $value : $this->exportNonScalar($value);
|
54 |
+
}
|
55 |
+
return $data;
|
|
|
56 |
}
|
|
|
|
|
|
|
57 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Request.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
+
|
27 |
+
class Request implements \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
const PROTOCOL_HTTP = 'http://';
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
const PROTOCOL_HTTPS = 'https://';
|
37 |
+
/**
|
38 |
+
* @var Client
|
39 |
+
*/
|
40 |
+
protected $client;
|
41 |
+
/**
|
42 |
+
* @var Headers
|
43 |
+
*/
|
44 |
+
protected $headers;
|
45 |
+
/**
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
protected $method = self::METHOD_GET;
|
49 |
+
/**
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $protocol = self::PROTOCOL_HTTPS;
|
53 |
+
/**
|
54 |
+
* @var string
|
55 |
+
*/
|
56 |
+
protected $domain;
|
57 |
+
/**
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
protected $path;
|
61 |
+
/**
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
protected $graphVersion;
|
65 |
+
/**
|
66 |
+
* @var Parameters
|
67 |
+
*/
|
68 |
+
protected $queryParams;
|
69 |
+
/**
|
70 |
+
* @var Parameters
|
71 |
+
*/
|
72 |
+
protected $bodyParams;
|
73 |
+
/**
|
74 |
+
* @var Parameters
|
75 |
+
*/
|
76 |
+
protected $fileParams;
|
77 |
+
/**
|
78 |
+
* @param Client $client
|
79 |
+
*/
|
80 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client)
|
81 |
+
{
|
82 |
+
$this->client = $client;
|
83 |
+
}
|
84 |
+
public function __clone()
|
85 |
+
{
|
86 |
+
$this->queryParams && ($this->queryParams = clone $this->queryParams);
|
87 |
+
$this->bodyParams && ($this->bodyParams = clone $this->bodyParams);
|
88 |
+
$this->fileParams && ($this->fileParams = clone $this->fileParams);
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* @return Client
|
92 |
+
*/
|
93 |
+
public function getClient()
|
94 |
+
{
|
95 |
+
return $this->client;
|
96 |
+
}
|
97 |
+
/**
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public function getProtocol()
|
101 |
+
{
|
102 |
+
return $this->protocol;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* @param string $protocol
|
106 |
+
*/
|
107 |
+
public function setProtocol($protocol)
|
108 |
+
{
|
109 |
+
$this->protocol = $protocol;
|
110 |
+
}
|
111 |
+
/**
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function getDomain()
|
115 |
+
{
|
116 |
+
if ($this->domain === null) {
|
117 |
+
$this->domain = \sprintf("%s.%s", \PixelCaffeine\Dependencies\FacebookAds\Http\Client::DEFAULT_LAST_LEVEL_DOMAIN, $this->client->getDefaultGraphBaseDomain());
|
118 |
+
}
|
119 |
+
return $this->domain;
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* @param string $domain
|
123 |
+
*/
|
124 |
+
public function setDomain($domain)
|
125 |
+
{
|
126 |
+
$this->domain = $domain;
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* @param string $last_level_domain
|
130 |
+
*/
|
131 |
+
public function setLastLevelDomain($last_level_domain)
|
132 |
+
{
|
133 |
+
$this->domain = \sprintf("%s.%s", $last_level_domain, $this->client->getDefaultGraphBaseDomain());
|
134 |
+
}
|
135 |
+
/**
|
136 |
+
* @return Headers
|
137 |
+
*/
|
138 |
+
public function getHeaders()
|
139 |
+
{
|
140 |
+
if ($this->headers === null) {
|
141 |
+
$this->headers = clone $this->getClient()->getDefaultRequestHeaderds();
|
142 |
+
}
|
143 |
+
return $this->headers;
|
144 |
+
}
|
145 |
+
/**
|
146 |
+
* @param Headers $headers
|
147 |
+
*/
|
148 |
+
public function setHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers)
|
149 |
+
{
|
150 |
+
$this->headers = $headers;
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
public function getMethod()
|
156 |
+
{
|
157 |
+
return $this->method;
|
158 |
+
}
|
159 |
+
/**
|
160 |
+
* @param string $method
|
161 |
+
*/
|
162 |
+
public function setMethod($method)
|
163 |
+
{
|
164 |
+
$this->method = $method;
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
public function getPath()
|
170 |
+
{
|
171 |
+
return $this->path;
|
172 |
+
}
|
173 |
+
/**
|
174 |
+
* @param string $path
|
175 |
+
*/
|
176 |
+
public function setPath($path)
|
177 |
+
{
|
178 |
+
$this->path = $path;
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* @return string
|
182 |
+
*/
|
183 |
+
public function getGraphVersion()
|
184 |
+
{
|
185 |
+
return $this->graphVersion;
|
186 |
+
}
|
187 |
+
/**
|
188 |
+
* @param string $version
|
189 |
+
*/
|
190 |
+
public function setGraphVersion($version)
|
191 |
+
{
|
192 |
+
$this->graphVersion = $version;
|
193 |
+
}
|
194 |
+
/**
|
195 |
+
* @return Parameters
|
196 |
+
*/
|
197 |
+
public function getQueryParams()
|
198 |
+
{
|
199 |
+
if ($this->queryParams === null) {
|
200 |
+
$this->queryParams = new \PixelCaffeine\Dependencies\FacebookAds\Http\Parameters();
|
201 |
+
}
|
202 |
+
return $this->queryParams;
|
203 |
+
}
|
204 |
+
/**
|
205 |
+
* @param Parameters $params
|
206 |
+
*/
|
207 |
+
public function setQueryParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params)
|
208 |
+
{
|
209 |
+
$this->queryParams = $params;
|
210 |
+
}
|
211 |
+
/**
|
212 |
+
* @return string
|
213 |
+
*/
|
214 |
+
public function getUrl()
|
215 |
+
{
|
216 |
+
$delimiter = null;
|
217 |
+
if ($this->getQueryParams()->count()) {
|
218 |
+
$delimiter = \strpos($this->getPath(), '?') ? '&' : '?';
|
219 |
+
}
|
220 |
+
return $this->getProtocol() . $this->getDomain() . '/v' . $this->getGraphVersion() . $this->getPath() . $delimiter . \http_build_query($this->getQueryParams()->export(), '', '&');
|
221 |
+
}
|
222 |
+
/**
|
223 |
+
* @return Parameters
|
224 |
+
*/
|
225 |
+
public function getBodyParams()
|
226 |
+
{
|
227 |
+
if ($this->bodyParams === null) {
|
228 |
+
$this->bodyParams = new \PixelCaffeine\Dependencies\FacebookAds\Http\Parameters();
|
229 |
+
}
|
230 |
+
return $this->bodyParams;
|
231 |
+
}
|
232 |
+
/**
|
233 |
+
* @param Parameters $params
|
234 |
+
*/
|
235 |
+
public function setBodyParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params)
|
236 |
+
{
|
237 |
+
$this->bodyParams = $params;
|
238 |
+
}
|
239 |
+
/**
|
240 |
+
* @return Parameters
|
241 |
+
*/
|
242 |
+
public function getFileParams()
|
243 |
+
{
|
244 |
+
if ($this->fileParams === null) {
|
245 |
+
$this->fileParams = new \PixelCaffeine\Dependencies\FacebookAds\Http\Parameters();
|
246 |
+
}
|
247 |
+
return $this->fileParams;
|
248 |
+
}
|
249 |
+
/**
|
250 |
+
* @param Parameters $params
|
251 |
+
*/
|
252 |
+
public function setFileParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params)
|
253 |
+
{
|
254 |
+
$this->fileParams = $params;
|
255 |
+
}
|
256 |
+
/**
|
257 |
+
* @return ResponseInterface
|
258 |
+
*/
|
259 |
+
public function execute()
|
260 |
+
{
|
261 |
+
return $this->getClient()->sendRequest($this);
|
262 |
+
}
|
263 |
+
/**
|
264 |
+
* @return Request
|
265 |
+
* @see RequestInterface::createClone()
|
266 |
+
*/
|
267 |
+
public function createClone()
|
268 |
+
{
|
269 |
+
return clone $this;
|
270 |
+
}
|
271 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/RequestInterface.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
+
|
27 |
+
interface RequestInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
const METHOD_DELETE = 'DELETE';
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
const METHOD_GET = 'GET';
|
37 |
+
/**
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
const METHOD_POST = 'POST';
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
const METHOD_PUT = 'PUT';
|
45 |
+
/**
|
46 |
+
* @param Client $client
|
47 |
+
*/
|
48 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client);
|
49 |
+
/**
|
50 |
+
* @return Client
|
51 |
+
*/
|
52 |
+
public function getClient();
|
53 |
+
/**
|
54 |
+
* @return Headers
|
55 |
+
*/
|
56 |
+
public function getHeaders();
|
57 |
+
/**
|
58 |
+
* @param Headers $headers
|
59 |
+
*/
|
60 |
+
public function setHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers);
|
61 |
+
/**
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getProtocol();
|
65 |
+
/**
|
66 |
+
* @param string $protocol
|
67 |
+
*/
|
68 |
+
public function setProtocol($protocol);
|
69 |
+
/**
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getDomain();
|
73 |
+
/**
|
74 |
+
* @param string $domain
|
75 |
+
*/
|
76 |
+
public function setDomain($domain);
|
77 |
+
/**
|
78 |
+
* @param string $last_level_domain
|
79 |
+
*/
|
80 |
+
public function setLastLevelDomain($last_level_domain);
|
81 |
+
/**
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function getMethod();
|
85 |
+
/**
|
86 |
+
* @param string $method
|
87 |
+
*/
|
88 |
+
public function setMethod($method);
|
89 |
+
/**
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
public function getPath();
|
93 |
+
/**
|
94 |
+
* @param string $version
|
95 |
+
*/
|
96 |
+
public function setGraphVersion($version);
|
97 |
+
/**
|
98 |
+
* @return mixed
|
99 |
+
*/
|
100 |
+
public function getGraphVersion();
|
101 |
+
/**
|
102 |
+
* @param string $path
|
103 |
+
*/
|
104 |
+
public function setPath($path);
|
105 |
+
/**
|
106 |
+
* @return Parameters
|
107 |
+
*/
|
108 |
+
public function getQueryParams();
|
109 |
+
/**
|
110 |
+
* @param Parameters $params
|
111 |
+
*/
|
112 |
+
public function setQueryParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params);
|
113 |
+
/**
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function getUrl();
|
117 |
+
/**
|
118 |
+
* @return Parameters
|
119 |
+
*/
|
120 |
+
public function getBodyParams();
|
121 |
+
/**
|
122 |
+
* @param Parameters $params
|
123 |
+
*/
|
124 |
+
public function setBodyParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params);
|
125 |
+
/**
|
126 |
+
* @return Parameters
|
127 |
+
*/
|
128 |
+
public function getFileParams();
|
129 |
+
/**
|
130 |
+
* @param Parameters $params
|
131 |
+
*/
|
132 |
+
public function setFileParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params);
|
133 |
+
/**
|
134 |
+
* @return ResponseInterface
|
135 |
+
*/
|
136 |
+
public function execute();
|
137 |
+
/**
|
138 |
+
* Required for Mocking request/response chaining
|
139 |
+
* @return RequestInterface
|
140 |
+
*/
|
141 |
+
public function createClone();
|
142 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Response.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
+
|
27 |
+
class Response implements \PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var RequestInterface
|
31 |
+
*/
|
32 |
+
protected $request;
|
33 |
+
/**
|
34 |
+
* @var int
|
35 |
+
*/
|
36 |
+
protected $statusCode;
|
37 |
+
/**
|
38 |
+
* @var Headers
|
39 |
+
*/
|
40 |
+
protected $headers;
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $body;
|
45 |
+
/**
|
46 |
+
* @var mixed
|
47 |
+
*/
|
48 |
+
protected $content;
|
49 |
+
/**
|
50 |
+
* @return RequestInterface
|
51 |
+
*/
|
52 |
+
public function getRequest()
|
53 |
+
{
|
54 |
+
return $this->request;
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* @param RequestInterface $request
|
58 |
+
*/
|
59 |
+
public function setRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request)
|
60 |
+
{
|
61 |
+
$this->request = $request;
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* @return int
|
65 |
+
*/
|
66 |
+
public function getStatusCode()
|
67 |
+
{
|
68 |
+
return $this->statusCode;
|
69 |
+
}
|
70 |
+
/**
|
71 |
+
* @param int $status_code
|
72 |
+
*/
|
73 |
+
public function setStatusCode($status_code)
|
74 |
+
{
|
75 |
+
$this->statusCode = $status_code;
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* @return Headers
|
79 |
+
*/
|
80 |
+
public function getHeaders()
|
81 |
+
{
|
82 |
+
if ($this->headers === null) {
|
83 |
+
$this->headers = new \PixelCaffeine\Dependencies\FacebookAds\Http\Headers();
|
84 |
+
}
|
85 |
+
return $this->headers;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* @param Headers $headers
|
89 |
+
*/
|
90 |
+
public function setHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers)
|
91 |
+
{
|
92 |
+
$this->headers = $headers;
|
93 |
+
}
|
94 |
+
/**
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function getBody()
|
98 |
+
{
|
99 |
+
return $this->body;
|
100 |
+
}
|
101 |
+
/**
|
102 |
+
* @param string $body
|
103 |
+
*/
|
104 |
+
public function setBody($body)
|
105 |
+
{
|
106 |
+
$this->body = $body;
|
107 |
+
$this->content = null;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* @return array|null
|
111 |
+
*/
|
112 |
+
public function getContent()
|
113 |
+
{
|
114 |
+
if ($this->content === null) {
|
115 |
+
$this->content = \json_decode($this->getBody(), \true);
|
116 |
+
}
|
117 |
+
return $this->content;
|
118 |
+
}
|
119 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/ResponseInterface.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,53 +22,44 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
/**
|
65 |
-
* @param string $body
|
66 |
-
*/
|
67 |
-
public function setBody($body);
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @return array|null
|
71 |
-
*/
|
72 |
-
public function getContent();
|
73 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
|
27 |
+
interface ResponseInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return RequestInterface
|
31 |
+
*/
|
32 |
+
public function getRequest();
|
33 |
+
/**
|
34 |
+
* @param RequestInterface $request
|
35 |
+
*/
|
36 |
+
public function setRequest(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request);
|
37 |
+
/**
|
38 |
+
* @return int
|
39 |
+
*/
|
40 |
+
public function getStatusCode();
|
41 |
+
/**
|
42 |
+
* @param int $status_code
|
43 |
+
*/
|
44 |
+
public function setStatusCode($status_code);
|
45 |
+
/**
|
46 |
+
* @return Headers
|
47 |
+
*/
|
48 |
+
public function getHeaders();
|
49 |
+
/**
|
50 |
+
* @param Headers $headers
|
51 |
+
*/
|
52 |
+
public function setHeaders(\PixelCaffeine\Dependencies\FacebookAds\Http\Headers $headers);
|
53 |
+
/**
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getBody();
|
57 |
+
/**
|
58 |
+
* @param string $body
|
59 |
+
*/
|
60 |
+
public function setBody($body);
|
61 |
+
/**
|
62 |
+
* @return array|null
|
63 |
+
*/
|
64 |
+
public function getContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Http/SimpleRequest.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
+
|
27 |
+
class SimpleRequest extends \PixelCaffeine\Dependencies\FacebookAds\Http\Request
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
const DEFAULT_WWWW_BASE_DOMAIN = 'connect.facebook.net';
|
33 |
+
/**
|
34 |
+
* @param Client $client
|
35 |
+
*/
|
36 |
+
public function __construct(\PixelCaffeine\Dependencies\FacebookAds\Http\Client $client)
|
37 |
+
{
|
38 |
+
parent::__construct($client);
|
39 |
+
//Setting the curl options inside the client to avoid SSL certificates usage
|
40 |
+
$client->getAdapter()->setOpts(new \ArrayObject(array(\CURLOPT_CONNECTTIMEOUT => 10, \CURLOPT_TIMEOUT => 60, \CURLOPT_RETURNTRANSFER => \true, \CURLOPT_HEADER => \true, \CURLOPT_SSL_VERIFYPEER => 0)));
|
41 |
+
}
|
42 |
+
/**
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getDomain()
|
46 |
+
{
|
47 |
+
if ($this->domain === null) {
|
48 |
+
$this->domain = \sprintf("%s", self::DEFAULT_WWWW_BASE_DOMAIN);
|
49 |
+
}
|
50 |
+
return $this->domain;
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getUrl()
|
56 |
+
{
|
57 |
+
$delimiter = null;
|
58 |
+
if ($this->getQueryParams()->count()) {
|
59 |
+
$delimiter = \strpos($this->getPath(), '?') ? '&' : '?';
|
60 |
+
}
|
61 |
+
return $this->getProtocol() . $this->getDomain() . '/' . $this->getPath() . $delimiter . \http_build_query($this->getQueryParams()->export(), '', '&');
|
62 |
+
}
|
63 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Http/Util.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,28 +22,27 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
44 |
}
|
45 |
-
|
46 |
-
return $query;
|
47 |
-
}
|
48 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Http;
|
26 |
|
27 |
+
abstract class Util
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* Avoid parse_str() for HHVM compatibility
|
31 |
+
* This implementation is not a complete sobstitute, but covers all the
|
32 |
+
* requirements of the Facebook Graph Cursor.
|
33 |
+
*
|
34 |
+
* @see hhvm.hack.disallow_dynamic_var_env_funcs
|
35 |
+
* @param $query_string
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public static function parseUrlQuery($query_string)
|
39 |
+
{
|
40 |
+
$query = array();
|
41 |
+
$pairs = \explode('&', $query_string);
|
42 |
+
foreach ($pairs as $pair) {
|
43 |
+
list($key, $value) = \explode('=', $pair);
|
44 |
+
$query[$key] = \urldecode($value);
|
45 |
+
}
|
46 |
+
return $query;
|
47 |
}
|
|
|
|
|
|
|
48 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Logger;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Parameters;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Logger\CurlLogger\JsonAwareParameters;
|
32 |
+
class CurlLogger implements \PixelCaffeine\Dependencies\FacebookAds\Logger\LoggerInterface
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
const PARAM_DEFAULT_FLAG = 'd';
|
38 |
+
/**
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
const PARAM_URLENCODE_FLAG = '-data-urlencode';
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
const PARAM_POST_FLAG = 'F';
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
const METHOD_DEFAULT_FLAG = '';
|
50 |
+
/**
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
const METHOD_GET_FLAG = 'G';
|
54 |
+
/**
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
const METHOD_PUT_FLAG = 'X PUT';
|
58 |
+
/**
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
const METHOD_DELETE_FLAG = 'X DELETE';
|
62 |
+
/**
|
63 |
+
* @var resource
|
64 |
+
*/
|
65 |
+
protected $handle;
|
66 |
+
/**
|
67 |
+
* @var bool
|
68 |
+
*/
|
69 |
+
protected $jsonPrettyPrint = \false;
|
70 |
+
/**
|
71 |
+
* @param resource $handle
|
72 |
+
*/
|
73 |
+
public function __construct($handle = null)
|
74 |
+
{
|
75 |
+
if (!\defined('STDOUT')) {
|
76 |
+
\define('STDOUT', \fopen('php://stdout', 'w'));
|
77 |
+
}
|
78 |
+
$this->handle = \is_resource($handle) ? $handle : \STDOUT;
|
79 |
+
}
|
80 |
+
/**
|
81 |
+
* @return bool
|
82 |
+
*/
|
83 |
+
public function isJsonPrettyPrint()
|
84 |
+
{
|
85 |
+
return $this->jsonPrettyPrint;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* @param bool $json_pretty_print
|
89 |
+
* @return $this
|
90 |
+
*/
|
91 |
+
public function setJsonPrettyPrint($json_pretty_print)
|
92 |
+
{
|
93 |
+
$this->jsonPrettyPrint = $json_pretty_print;
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* @param string $method
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public static function getMethodFlag($method)
|
101 |
+
{
|
102 |
+
switch ($method) {
|
103 |
+
case \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET:
|
104 |
+
return static::METHOD_GET_FLAG;
|
105 |
+
case \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_PUT:
|
106 |
+
return static::METHOD_PUT_FLAG;
|
107 |
+
case \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_DELETE:
|
108 |
+
return static::METHOD_DELETE_FLAG;
|
109 |
+
}
|
110 |
+
return static::METHOD_DEFAULT_FLAG;
|
111 |
+
}
|
112 |
+
/**
|
113 |
+
* @param string $method
|
114 |
+
* @param string $value
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public static function getParamFlag($method, $value)
|
118 |
+
{
|
119 |
+
return $method === \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST ? static::PARAM_POST_FLAG : (\strstr($value, "\n") ? static::PARAM_URLENCODE_FLAG : static::PARAM_DEFAULT_FLAG);
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* @param string $string
|
123 |
+
* @param int $indent
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
protected function indent($string, $indent)
|
127 |
+
{
|
128 |
+
return \str_replace("\n", " \n" . \str_repeat(' ', $indent), $string);
|
129 |
+
}
|
130 |
+
/**
|
131 |
+
* @param Parameters $params
|
132 |
+
* @param string $method
|
133 |
+
* @param bool $is_file
|
134 |
+
* @return string
|
135 |
+
*/
|
136 |
+
protected function processParams(\PixelCaffeine\Dependencies\FacebookAds\Http\Parameters $params, $method, $is_file)
|
137 |
+
{
|
138 |
+
$chunks = array();
|
139 |
+
if ($this->isJsonPrettyPrint()) {
|
140 |
+
$params = new \PixelCaffeine\Dependencies\FacebookAds\Logger\CurlLogger\JsonAwareParameters($params);
|
141 |
+
}
|
142 |
+
foreach ($params->export() as $name => $value) {
|
143 |
+
if ($is_file && $params->offsetGet($name) instanceof \PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter) {
|
144 |
+
$value = "@" . $this->normalizeFileParam($params->offsetGet($name));
|
145 |
+
} else {
|
146 |
+
$value = \addcslashes(\strpos($value, "\n") !== \false ? $this->indent($value, 2) : $value, '\'');
|
147 |
+
}
|
148 |
+
$chunks[$name] = \sprintf('-%s \'%s=%s\'', $this->getParamFlag($method, $value), $name, $value);
|
149 |
+
}
|
150 |
+
return $chunks;
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* @param FileParameter $file_param
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
protected function normalizeFileParam(\PixelCaffeine\Dependencies\FacebookAds\Http\FileParameter $file_param)
|
157 |
+
{
|
158 |
+
return \sprintf('%s%s%s%s%s', $file_param->getPath(), $file_param->getMimeType() != null ? ";type=" : "", $file_param->getMimeType(), $file_param->getName() != null ? ";name=" : "", $file_param->getName());
|
159 |
+
}
|
160 |
+
/**
|
161 |
+
* @param RequestInterface $request
|
162 |
+
* @return string
|
163 |
+
*/
|
164 |
+
protected function processUrl(\PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request)
|
165 |
+
{
|
166 |
+
return $request->getProtocol() . $request->getDomain() . '/v' . $request->getGraphVersion() . $request->getPath();
|
167 |
+
}
|
168 |
+
/**
|
169 |
+
* @param string $buffer
|
170 |
+
*/
|
171 |
+
protected function flush($buffer)
|
172 |
+
{
|
173 |
+
\fwrite($this->handle, $buffer . \PHP_EOL . \PHP_EOL);
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* @param mixed $level
|
177 |
+
* @param string $message
|
178 |
+
* @param array $context
|
179 |
+
*/
|
180 |
+
public function log($level, $message, array $context = array())
|
181 |
+
{
|
182 |
+
// We only care about requests
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* @param array $array
|
186 |
+
* @param mixed $key
|
187 |
+
* @return mixed
|
188 |
+
*/
|
189 |
+
protected function removeArrayKey(array &$array, $key)
|
190 |
+
{
|
191 |
+
if (\array_key_exists($key, $array)) {
|
192 |
+
$value = $array[$key];
|
193 |
+
unset($array[$key]);
|
194 |
+
return $value;
|
195 |
+
} else {
|
196 |
+
return null;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
/**
|
200 |
+
* @param array $params
|
201 |
+
* @return array
|
202 |
+
*/
|
203 |
+
protected function sortParams(array $params)
|
204 |
+
{
|
205 |
+
$access_token = $this->removeArrayKey($params, 'access_token');
|
206 |
+
$appsecret_proof = $this->removeArrayKey($params, 'appsecret_proof');
|
207 |
+
$access_token !== null && ($params['access_token'] = $access_token);
|
208 |
+
$appsecret_proof !== null && ($params['appsecret_proof'] = $appsecret_proof);
|
209 |
+
return $params;
|
210 |
+
}
|
211 |
+
/**
|
212 |
+
* @param string $level
|
213 |
+
* @param RequestInterface $request
|
214 |
+
* @param array $context
|
215 |
+
*/
|
216 |
+
public function logRequest($level, \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request, array $context = array())
|
217 |
+
{
|
218 |
+
$new_line = ' \\' . \PHP_EOL . ' ';
|
219 |
+
$method = $request->getMethod();
|
220 |
+
$method_flag = static::getMethodFlag($method);
|
221 |
+
$params = $this->sortParams(\array_merge($this->processParams($request->getQueryParams(), $method, \false), $this->processParams($request->getBodyParams(), $method, \false), $this->processParams($request->getFileParams(), $method, \true)));
|
222 |
+
$buffer = 'curl' . ($method_flag ? ' -' . $method_flag : '');
|
223 |
+
foreach ($params as $param) {
|
224 |
+
$buffer .= $new_line . $param;
|
225 |
+
}
|
226 |
+
$buffer .= $new_line . $this->processUrl($request);
|
227 |
+
$this->flush($buffer);
|
228 |
+
}
|
229 |
+
/**
|
230 |
+
* @param string $level
|
231 |
+
* @param ResponseInterface $response
|
232 |
+
* @param array $context
|
233 |
+
*/
|
234 |
+
public function logResponse($level, \PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response, array $context = array())
|
235 |
+
{
|
236 |
+
// We only care about requests
|
237 |
+
}
|
238 |
+
}
|
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php → third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonAwareParameters.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,24 +22,17 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
public static function getInstance() {
|
37 |
-
$fqn = get_called_class();
|
38 |
-
if (!array_key_exists($fqn, static::$instances)) {
|
39 |
-
static::$instances[$fqn] = new static();
|
40 |
}
|
41 |
-
|
42 |
-
return static::$instances[$fqn];
|
43 |
-
}
|
44 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Logger\CurlLogger;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Parameters;
|
28 |
+
class JsonAwareParameters extends \PixelCaffeine\Dependencies\FacebookAds\Http\Parameters
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @param mixed $value
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
protected function exportNonScalar($value)
|
35 |
+
{
|
36 |
+
return \PixelCaffeine\Dependencies\FacebookAds\Logger\CurlLogger\JsonNode::factory($value)->encode();
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
|
|
|
|
|
|
38 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/CurlLogger/JsonNode.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Logger\CurlLogger;
|
26 |
+
|
27 |
+
final class JsonNode
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var int
|
31 |
+
*/
|
32 |
+
const INDENT_UNIT = 2;
|
33 |
+
/**
|
34 |
+
* @var int
|
35 |
+
*/
|
36 |
+
const EXPLOSION_THRESHOLD = 78;
|
37 |
+
/**
|
38 |
+
* @var mixed
|
39 |
+
*/
|
40 |
+
protected $value;
|
41 |
+
/**
|
42 |
+
* @var \ArrayObject
|
43 |
+
*/
|
44 |
+
protected $children;
|
45 |
+
/**
|
46 |
+
* @param mixed $value
|
47 |
+
* @return $this
|
48 |
+
* @throws \InvalidArgumentException
|
49 |
+
*/
|
50 |
+
public static function factory($value)
|
51 |
+
{
|
52 |
+
$object = new self();
|
53 |
+
switch (\true) {
|
54 |
+
case \is_object($value):
|
55 |
+
$value = (array) $value;
|
56 |
+
// fallthrough
|
57 |
+
case \is_array($value):
|
58 |
+
foreach ($value as $key => $sub) {
|
59 |
+
$object->getChildren()->offsetSet($key, self::factory($sub));
|
60 |
+
}
|
61 |
+
// fallthrough
|
62 |
+
case \is_null($value) || \is_scalar($value):
|
63 |
+
$object->setValue($value);
|
64 |
+
break;
|
65 |
+
default:
|
66 |
+
throw new \InvalidArgumentException(\gettype($value) . ' can\'t be encoded');
|
67 |
+
}
|
68 |
+
return $object;
|
69 |
+
}
|
70 |
+
public function __construct()
|
71 |
+
{
|
72 |
+
$this->children = new \ArrayObject();
|
73 |
+
}
|
74 |
+
/**
|
75 |
+
* @return mixed
|
76 |
+
*/
|
77 |
+
public function getValue()
|
78 |
+
{
|
79 |
+
return $this->value;
|
80 |
+
}
|
81 |
+
/**
|
82 |
+
* @param mixed $value
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
public function setValue($value)
|
86 |
+
{
|
87 |
+
$this->value = $value;
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* @return \ArrayObject
|
92 |
+
*/
|
93 |
+
public function getChildren()
|
94 |
+
{
|
95 |
+
return $this->children;
|
96 |
+
}
|
97 |
+
/**
|
98 |
+
* @return int
|
99 |
+
*/
|
100 |
+
public function getMaxTreeChildrenCount()
|
101 |
+
{
|
102 |
+
$max = $this->getChildren()->count();
|
103 |
+
/** @var JsonNode $child */
|
104 |
+
foreach ($this->getChildren() as $child) {
|
105 |
+
$ith = $child->getMaxTreeChildrenCount();
|
106 |
+
$max = $ith > $max ? $ith : $max;
|
107 |
+
}
|
108 |
+
return $max;
|
109 |
+
}
|
110 |
+
/**
|
111 |
+
* @param int $indent
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
protected function getPadding($indent)
|
115 |
+
{
|
116 |
+
return \str_repeat(' ', $indent * self::INDENT_UNIT);
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* @return mixed
|
120 |
+
*/
|
121 |
+
protected function getLastChildKey()
|
122 |
+
{
|
123 |
+
if ($this->getChildren()->count() === 0) {
|
124 |
+
return null;
|
125 |
+
}
|
126 |
+
$copy = $this->getChildren()->getArrayCopy();
|
127 |
+
\end($copy);
|
128 |
+
return \key($copy);
|
129 |
+
}
|
130 |
+
/**
|
131 |
+
* @param int $indent
|
132 |
+
* @return string
|
133 |
+
*/
|
134 |
+
protected function encodeList($indent)
|
135 |
+
{
|
136 |
+
$value = $this->getValue();
|
137 |
+
if (empty($value) || \array_keys($value) === \range(0, \count($value) - 1)) {
|
138 |
+
$is_map = \false;
|
139 |
+
} else {
|
140 |
+
$is_map = \true;
|
141 |
+
}
|
142 |
+
++$indent;
|
143 |
+
$last_key = $this->getLastChildKey();
|
144 |
+
$buffer = ($is_map ? '{' : '[') . "\n";
|
145 |
+
/** @var JsonNode $child */
|
146 |
+
foreach ($this->getChildren() as $key => $child) {
|
147 |
+
$buffer .= \sprintf("%s%s%s%s\n", $this->getPadding($indent), $is_map ? \sprintf("%s: ", \json_encode($key)) : '', $child->encode($indent), $key === $last_key ? '' : ',');
|
148 |
+
}
|
149 |
+
--$indent;
|
150 |
+
$buffer .= $this->getPadding($indent) . ($is_map ? '}' : ']');
|
151 |
+
return $buffer;
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* @param int $indent
|
155 |
+
* @return string
|
156 |
+
*/
|
157 |
+
public function encode($indent = 0)
|
158 |
+
{
|
159 |
+
$value = $this->getValue();
|
160 |
+
if (\is_array($value) || \is_object($value)) {
|
161 |
+
if ($this->getMaxTreeChildrenCount() > 2) {
|
162 |
+
return $this->encodeList($indent);
|
163 |
+
}
|
164 |
+
$ugly = \json_encode($value);
|
165 |
+
$output_prediction = $this->getPadding($indent) . $ugly;
|
166 |
+
if (\strlen($output_prediction) > self::EXPLOSION_THRESHOLD) {
|
167 |
+
return $this->encodeList($indent);
|
168 |
+
}
|
169 |
+
return $ugly;
|
170 |
+
}
|
171 |
+
return \json_encode($value);
|
172 |
+
}
|
173 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Logger/LoggerInterface.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,34 +22,28 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @param string $level
|
49 |
-
* @param ResponseInterface $response
|
50 |
-
* @param array $context
|
51 |
-
*/
|
52 |
-
public function logResponse(
|
53 |
-
$level, ResponseInterface $response, array $context = array());
|
54 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Logger;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
29 |
+
interface LoggerInterface
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* @param string $level
|
33 |
+
* @param string $message
|
34 |
+
* @param array $context
|
35 |
+
*/
|
36 |
+
public function log($level, $message, array $context = array());
|
37 |
+
/**
|
38 |
+
* @param string $level
|
39 |
+
* @param RequestInterface $request
|
40 |
+
* @param array $context
|
41 |
+
*/
|
42 |
+
public function logRequest($level, \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request, array $context = array());
|
43 |
+
/**
|
44 |
+
* @param string $level
|
45 |
+
* @param ResponseInterface $response
|
46 |
+
* @param array $context
|
47 |
+
*/
|
48 |
+
public function logResponse($level, \PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response, array $context = array());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Logger/NullLogger.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Logger;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
29 |
+
class NullLogger implements \PixelCaffeine\Dependencies\FacebookAds\Logger\LoggerInterface
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* @param string $level
|
33 |
+
* @param string $message
|
34 |
+
* @param array $context
|
35 |
+
*/
|
36 |
+
public function log($level, $message, array $context = array())
|
37 |
+
{
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* @param string $level
|
41 |
+
* @param RequestInterface $request
|
42 |
+
* @param array $context
|
43 |
+
*/
|
44 |
+
public function logRequest($level, \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface $request, array $context = array())
|
45 |
+
{
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* @param string $level
|
49 |
+
* @param ResponseInterface $response
|
50 |
+
* @param array $context
|
51 |
+
*/
|
52 |
+
public function logResponse($level, \PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface $response, array $context = array())
|
53 |
+
{
|
54 |
+
}
|
55 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractArchivableCrudObject.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
28 |
+
abstract class AbstractArchivableCrudObject extends \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractCrudObject
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
const STATUS_PARAM_NAME = 'status';
|
34 |
+
/**
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
const STATUS_ACTIVE = 'ACTIVE';
|
38 |
+
/**
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
const STATUS_PAUSED = 'PAUSED';
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
const STATUS_DELETED = 'DELETED';
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
const STATUS_ARCHIVED = 'ARCHIVED';
|
50 |
+
/**
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function getStatusParamName()
|
54 |
+
{
|
55 |
+
return self::STATUS_PARAM_NAME;
|
56 |
+
}
|
57 |
+
/**
|
58 |
+
* Archive this object
|
59 |
+
*
|
60 |
+
* @deprecated use api_update instead
|
61 |
+
* @param array $params
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
public function archive(array $params = array())
|
65 |
+
{
|
66 |
+
$this->getApi()->call($this->getNodePath(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, \array_merge($params, array($this->getStatusParamName() => static::STATUS_ARCHIVED)));
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* Delete this object
|
70 |
+
*
|
71 |
+
* @deprecated use api_update instead
|
72 |
+
* @param array $params
|
73 |
+
* @return void
|
74 |
+
*/
|
75 |
+
public function delete(array $params = array())
|
76 |
+
{
|
77 |
+
$this->getApi()->call($this->getNodePath(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, \array_merge($params, array($this->getStatusParamName() => static::STATUS_DELETED)));
|
78 |
+
}
|
79 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractCrudObject.php
ADDED
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Cursor;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\ResponseInterface;
|
31 |
+
class AbstractCrudObject extends \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
const FIELD_ID = 'id';
|
37 |
+
/**
|
38 |
+
* @var string[] set of fields to read by default
|
39 |
+
*/
|
40 |
+
protected static $defaultReadFields = array();
|
41 |
+
/**
|
42 |
+
* @var array set of fields that have been mutated
|
43 |
+
*/
|
44 |
+
protected $changedFields = array();
|
45 |
+
/**
|
46 |
+
* @var Api instance of the Api used by this object
|
47 |
+
*/
|
48 |
+
protected $api;
|
49 |
+
/**
|
50 |
+
* @var string ID of the adaccount this object belongs to
|
51 |
+
*/
|
52 |
+
protected $parentId;
|
53 |
+
/**
|
54 |
+
* @deprecated deprecate constructor with null and parent_id
|
55 |
+
* @param string $id Optional (do not set for new objects)
|
56 |
+
* @param string $parent_id Optional, needed for creating new objects.
|
57 |
+
* @param Api $api The Api instance this object should use to make calls
|
58 |
+
*/
|
59 |
+
public function __construct($id = null, $parent_id = null, \PixelCaffeine\Dependencies\FacebookAds\Api $api = null)
|
60 |
+
{
|
61 |
+
parent::__construct();
|
62 |
+
// check that $id is an integer or a string integer or a string of
|
63 |
+
// two integer connected by an underscore, like "123_456"
|
64 |
+
$int_id = $id;
|
65 |
+
if (\strpos($id, 'act_') === 0) {
|
66 |
+
$int_id = \substr($id, 4);
|
67 |
+
}
|
68 |
+
$split_by_underscore = \explode('_', (string) $id);
|
69 |
+
$is_regular_id = \sizeof($split_by_underscore) == 2 && \ctype_digit($split_by_underscore[0]) && \ctype_digit($split_by_underscore[1]);
|
70 |
+
if (!\is_null($int_id) && !\ctype_digit((string) $int_id) && !$is_regular_id) {
|
71 |
+
$extra_message = '';
|
72 |
+
if (\is_numeric($int_id)) {
|
73 |
+
$extra_message = ' Please use an integer string' . ' to prevent integer overflow.';
|
74 |
+
}
|
75 |
+
throw new \InvalidArgumentException('Object ID must be an integer or integer string but was passed "' . (string) $id . '" (' . \gettype($id) . ').' . (string) $extra_message);
|
76 |
+
}
|
77 |
+
$this->data[static::FIELD_ID] = $id;
|
78 |
+
if (!\is_null($parent_id)) {
|
79 |
+
$warning_message = "\$parent_id as a parameter of constructor is being " . "deprecated, please try not to use this in new code.\n";
|
80 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
81 |
+
}
|
82 |
+
$this->parentId = $parent_id;
|
83 |
+
$this->api = static::assureApi($api);
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* @param string $id
|
87 |
+
*/
|
88 |
+
public function setId($id)
|
89 |
+
{
|
90 |
+
$this->data[static::FIELD_ID] = $id;
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* @deprecated deprecate parent_id in AbstractCrudObject
|
95 |
+
* @param string $parent_id
|
96 |
+
*/
|
97 |
+
public function setParentId($parent_id)
|
98 |
+
{
|
99 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
100 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
101 |
+
$this->parentId = $parent_id;
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* @param Api $api The Api instance this object should use to make calls
|
106 |
+
*/
|
107 |
+
public function setApi(\PixelCaffeine\Dependencies\FacebookAds\Api $api)
|
108 |
+
{
|
109 |
+
$this->api = static::assureApi($api);
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
/**
|
113 |
+
* @deprecated getEndpoint function is deprecated
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
protected function getEndpoint()
|
117 |
+
{
|
118 |
+
return null;
|
119 |
+
}
|
120 |
+
/**
|
121 |
+
* @param Api|null $instance
|
122 |
+
* @return Api
|
123 |
+
* @throws \InvalidArgumentException
|
124 |
+
*/
|
125 |
+
protected static function assureApi(\PixelCaffeine\Dependencies\FacebookAds\Api $instance = null)
|
126 |
+
{
|
127 |
+
$instance = $instance ?: \PixelCaffeine\Dependencies\FacebookAds\Api::instance();
|
128 |
+
if (!$instance) {
|
129 |
+
throw new \InvalidArgumentException('An Api instance must be provided as argument or ' . 'set as instance in the \\FacebookAds\\Api');
|
130 |
+
}
|
131 |
+
return $instance;
|
132 |
+
}
|
133 |
+
/**
|
134 |
+
* @deprecated deprecate parent_id in AbstractCrudObject
|
135 |
+
* @return string|null
|
136 |
+
*/
|
137 |
+
public function getParentId()
|
138 |
+
{
|
139 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
140 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
141 |
+
return $this->parentId;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* @deprecated deprecate parent_id in AbstractCrudObject
|
145 |
+
* @return string
|
146 |
+
* @throws \Exception
|
147 |
+
*/
|
148 |
+
protected function assureParentId()
|
149 |
+
{
|
150 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
151 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
152 |
+
if (!$this->parentId) {
|
153 |
+
throw new \Exception("A parent ID is required.");
|
154 |
+
}
|
155 |
+
return $this->parentId;
|
156 |
+
}
|
157 |
+
/**
|
158 |
+
* @return string
|
159 |
+
* @throws \Exception
|
160 |
+
*/
|
161 |
+
protected function assureId()
|
162 |
+
{
|
163 |
+
if (!$this->data[static::FIELD_ID]) {
|
164 |
+
throw new \Exception("field '" . static::FIELD_ID . "' is required.");
|
165 |
+
}
|
166 |
+
return (string) $this->data[static::FIELD_ID];
|
167 |
+
}
|
168 |
+
/**
|
169 |
+
* @return Api
|
170 |
+
*/
|
171 |
+
public function getApi()
|
172 |
+
{
|
173 |
+
return $this->api;
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* Get the values which have changed
|
177 |
+
*
|
178 |
+
* @return array Key value pairs of changed variables
|
179 |
+
*/
|
180 |
+
public function getChangedValues()
|
181 |
+
{
|
182 |
+
return $this->changedFields;
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* Get the name of the fields that have changed
|
186 |
+
*
|
187 |
+
* @return array Array of changed field names
|
188 |
+
*/
|
189 |
+
public function getChangedFields()
|
190 |
+
{
|
191 |
+
return \array_keys($this->changedFields);
|
192 |
+
}
|
193 |
+
/**
|
194 |
+
* Get the values which have changed, converting them to scalars
|
195 |
+
*/
|
196 |
+
public function exportData()
|
197 |
+
{
|
198 |
+
$data = array();
|
199 |
+
foreach ($this->changedFields as $key => $val) {
|
200 |
+
$data[$key] = parent::exportValue($val);
|
201 |
+
}
|
202 |
+
return $data;
|
203 |
+
}
|
204 |
+
/**
|
205 |
+
* @return void
|
206 |
+
*/
|
207 |
+
protected function clearHistory()
|
208 |
+
{
|
209 |
+
$this->changedFields = array();
|
210 |
+
}
|
211 |
+
/**
|
212 |
+
* @param string $name
|
213 |
+
* @param mixed $value
|
214 |
+
*/
|
215 |
+
public function __set($name, $value)
|
216 |
+
{
|
217 |
+
if (!\array_key_exists($name, $this->data) || $this->data[$name] !== $value) {
|
218 |
+
$this->changedFields[$name] = $value;
|
219 |
+
}
|
220 |
+
parent::__set($name, $value);
|
221 |
+
}
|
222 |
+
/**
|
223 |
+
* @param string[] $fields
|
224 |
+
*/
|
225 |
+
public static function setDefaultReadFields(array $fields = array())
|
226 |
+
{
|
227 |
+
static::$defaultReadFields = $fields;
|
228 |
+
}
|
229 |
+
/**
|
230 |
+
* @return string[]
|
231 |
+
*/
|
232 |
+
public static function getDefaultReadFields()
|
233 |
+
{
|
234 |
+
return static::$defaultReadFields;
|
235 |
+
}
|
236 |
+
/**
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
protected function getNodePath()
|
240 |
+
{
|
241 |
+
return '/' . $this->assureId();
|
242 |
+
}
|
243 |
+
/**
|
244 |
+
* @deprecated
|
245 |
+
* use (ParentObject)->creatXXX() instead
|
246 |
+
* Create function for the object.
|
247 |
+
*
|
248 |
+
* @param array $params Additional parameters to include in the request
|
249 |
+
* @return $this
|
250 |
+
* @throws \Exception
|
251 |
+
*/
|
252 |
+
public function create(array $params = array())
|
253 |
+
{
|
254 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
255 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
256 |
+
if ($this->data[static::FIELD_ID]) {
|
257 |
+
throw new \Exception("Object has already an ID");
|
258 |
+
}
|
259 |
+
$response = $this->getApi()->call('/' . $this->assureParentId() . '/' . $this->getEndpoint(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, \array_merge($this->exportData(), $params));
|
260 |
+
$this->clearHistory();
|
261 |
+
$data = $response->getContent();
|
262 |
+
if (!isset($params['execution_options'])) {
|
263 |
+
$id = \is_string($data) ? $data : $data[static::FIELD_ID];
|
264 |
+
/** @var AbstractCrudObject $this */
|
265 |
+
if ($this instanceof \PixelCaffeine\Dependencies\FacebookAds\Object\CanRedownloadInterface && isset($params[\PixelCaffeine\Dependencies\FacebookAds\Object\CanRedownloadInterface::PARAM_REDOWNLOAD]) && $params[\PixelCaffeine\Dependencies\FacebookAds\Object\CanRedownloadInterface::PARAM_REDOWNLOAD] === \true && isset($data['data'][$id]) && \is_array($data['data'][$id])) {
|
266 |
+
$this->setDataWithoutValidation($data['data'][$id]);
|
267 |
+
}
|
268 |
+
$this->data[static::FIELD_ID] = (string) $id;
|
269 |
+
}
|
270 |
+
return $this;
|
271 |
+
}
|
272 |
+
/**
|
273 |
+
* @deprecated
|
274 |
+
* use getSelf() instead
|
275 |
+
* Read object data from the graph
|
276 |
+
*
|
277 |
+
* @param string[] $fields Fields to request
|
278 |
+
* @param array $params Additional request parameters
|
279 |
+
* @return $this
|
280 |
+
*/
|
281 |
+
public function read(array $fields = array(), array $params = array())
|
282 |
+
{
|
283 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
284 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
285 |
+
$fields = \implode(',', $fields ?: static::getDefaultReadFields());
|
286 |
+
if ($fields) {
|
287 |
+
$params['fields'] = $fields;
|
288 |
+
}
|
289 |
+
$response = $this->getApi()->call($this->getNodePath(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, $params);
|
290 |
+
$this->setDataWithoutValidation($response->getContent());
|
291 |
+
$this->clearHistory();
|
292 |
+
return $this;
|
293 |
+
}
|
294 |
+
/**
|
295 |
+
* @deprecated
|
296 |
+
* use updateSelf() instead
|
297 |
+
* Update the object. Function parameters are similar with the create function
|
298 |
+
*
|
299 |
+
* @param array $params Update parameters in assoc
|
300 |
+
* @return $this
|
301 |
+
*/
|
302 |
+
public function update(array $params = array())
|
303 |
+
{
|
304 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
305 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
306 |
+
$this->getApi()->call($this->getNodePath(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, \array_merge($this->exportData(), $params));
|
307 |
+
$this->clearHistory();
|
308 |
+
return $this;
|
309 |
+
}
|
310 |
+
/**
|
311 |
+
* @deprecated
|
312 |
+
* use deleteSelf() in each subclass
|
313 |
+
* Delete this object from the graph
|
314 |
+
*
|
315 |
+
* @param array $params
|
316 |
+
* @return void
|
317 |
+
*/
|
318 |
+
public function deleteSelf(array $params = array())
|
319 |
+
{
|
320 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
321 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
322 |
+
$this->getApi()->call($this->getNodePath(), \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_DELETE, $params);
|
323 |
+
}
|
324 |
+
/**
|
325 |
+
* @deprecated
|
326 |
+
* deprecate with ObjectValidation
|
327 |
+
* Perform object upsert
|
328 |
+
*
|
329 |
+
* Helper function which determines whether an object should be created or
|
330 |
+
* updated
|
331 |
+
*
|
332 |
+
* @param array $params
|
333 |
+
* @return $this
|
334 |
+
*/
|
335 |
+
public function save(array $params = array())
|
336 |
+
{
|
337 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
338 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
339 |
+
if ($this->data[static::FIELD_ID]) {
|
340 |
+
return $this->update($params);
|
341 |
+
} else {
|
342 |
+
return $this->create($params);
|
343 |
+
}
|
344 |
+
}
|
345 |
+
/**
|
346 |
+
* @deprecated
|
347 |
+
* deprecate with getEndpoint
|
348 |
+
* @param string $prototype_class
|
349 |
+
* @param string $endpoint
|
350 |
+
* @return string
|
351 |
+
* @throws \InvalidArgumentException
|
352 |
+
*/
|
353 |
+
protected function assureEndpoint($prototype_class, $endpoint)
|
354 |
+
{
|
355 |
+
$warning_message = \sprintf('%s is being deprecated, please try not to use' . ' this in new code.', __FUNCTION__);
|
356 |
+
\trigger_error($warning_message, \E_USER_DEPRECATED);
|
357 |
+
if (!$endpoint) {
|
358 |
+
$prototype = new $prototype_class(null, null, $this->getApi());
|
359 |
+
if (!$prototype instanceof \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractCrudObject) {
|
360 |
+
throw new \InvalidArgumentException('Either prototype must be instance
|
361 |
+
of AbstractCrudObject or $endpoint must be given');
|
362 |
+
}
|
363 |
+
$endpoint = $prototype->getEndpoint();
|
364 |
+
}
|
365 |
+
return $endpoint;
|
366 |
+
}
|
367 |
+
/**
|
368 |
+
* @param array $fields
|
369 |
+
* @param array $params
|
370 |
+
* @param string $prototype_class
|
371 |
+
* @param string|null $endpoint
|
372 |
+
* @return ResponseInterface
|
373 |
+
*/
|
374 |
+
protected function fetchConnection(array $fields = array(), array $params = array(), $prototype_class = '', $endpoint = null)
|
375 |
+
{
|
376 |
+
$fields = \implode(',', $fields ?: static::getDefaultReadFields());
|
377 |
+
if ($fields) {
|
378 |
+
$params['fields'] = $fields;
|
379 |
+
}
|
380 |
+
$endpoint = $this->assureEndpoint($prototype_class, $endpoint);
|
381 |
+
return $this->getApi()->call('/' . $this->assureId() . '/' . $endpoint, \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, $params);
|
382 |
+
}
|
383 |
+
/**
|
384 |
+
* Read a single connection object
|
385 |
+
*
|
386 |
+
* @param string $prototype_class
|
387 |
+
* @param array $fields Fields to request
|
388 |
+
* @param array $params Additional filters for the reading
|
389 |
+
* @param string|null $endpoint
|
390 |
+
* @return AbstractObject
|
391 |
+
*/
|
392 |
+
protected function getOneByConnection($prototype_class, array $fields = array(), array $params = array(), $endpoint = null)
|
393 |
+
{
|
394 |
+
$response = $this->fetchConnection($fields, $params, $prototype_class, $endpoint);
|
395 |
+
if (!$response->getContent()) {
|
396 |
+
return null;
|
397 |
+
}
|
398 |
+
$object = new $prototype_class(null, null, $this->getApi());
|
399 |
+
/** @var AbstractCrudObject $object */
|
400 |
+
$object->setDataWithoutValidation($response->getContent());
|
401 |
+
return $object;
|
402 |
+
}
|
403 |
+
/**
|
404 |
+
* Read objects from a connection
|
405 |
+
*
|
406 |
+
* @param string $prototype_class
|
407 |
+
* @param array $fields Fields to request
|
408 |
+
* @param array $params Additional filters for the reading
|
409 |
+
* @param string|null $endpoint
|
410 |
+
* @return Cursor
|
411 |
+
*/
|
412 |
+
protected function getManyByConnection($prototype_class, array $fields = array(), array $params = array(), $endpoint = null)
|
413 |
+
{
|
414 |
+
$response = $this->fetchConnection($fields, $params, $prototype_class, $endpoint);
|
415 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Cursor($response, new $prototype_class(null, null, $this->getApi()));
|
416 |
+
}
|
417 |
+
/**
|
418 |
+
* @param string $job_class
|
419 |
+
* @param array $fields
|
420 |
+
* @param array $params
|
421 |
+
* @return AbstractAsyncJobObject
|
422 |
+
* @throws \InvalidArgumentException
|
423 |
+
*/
|
424 |
+
protected function createAsyncJob($job_class, array $fields = array(), array $params = array())
|
425 |
+
{
|
426 |
+
$object = new $job_class(null, $this->assureId(), $this->getApi());
|
427 |
+
if (!$object instanceof \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractAsyncJobObject) {
|
428 |
+
throw new \InvalidArgumentException("Class {$job_class} is not of type " . \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractAsyncJobObject::className());
|
429 |
+
}
|
430 |
+
$params['fields'] = $fields;
|
431 |
+
return $object->create($params);
|
432 |
+
}
|
433 |
+
/**
|
434 |
+
* Delete objects.
|
435 |
+
*
|
436 |
+
* Used batch API calls to delete multiple objects at once
|
437 |
+
*
|
438 |
+
* @param string[] $ids Array or single Object ID to delete
|
439 |
+
* @param Api $api Api Object to use
|
440 |
+
* @return bool Returns true on success
|
441 |
+
*/
|
442 |
+
public static function deleteIds(array $ids, \PixelCaffeine\Dependencies\FacebookAds\Api $api = null)
|
443 |
+
{
|
444 |
+
$batch = array();
|
445 |
+
foreach ($ids as $id) {
|
446 |
+
$request = array('relative_url' => '/' . $id, 'method' => \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_DELETE);
|
447 |
+
$batch[] = $request;
|
448 |
+
}
|
449 |
+
$api = static::assureApi($api);
|
450 |
+
$response = $api->call('/', \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, array('batch' => \json_encode($batch)));
|
451 |
+
foreach ($response->getContent() as $result) {
|
452 |
+
if (200 != $result['code']) {
|
453 |
+
return \false;
|
454 |
+
}
|
455 |
+
}
|
456 |
+
return \true;
|
457 |
+
}
|
458 |
+
/**
|
459 |
+
* Read function for the object. Convert fields and filters into the query
|
460 |
+
* part of uri and return objects.
|
461 |
+
*
|
462 |
+
* @param mixed $ids Array or single object IDs
|
463 |
+
* @param array $fields Array of field names to read
|
464 |
+
* @param array $params Additional filters for the reading, in assoc
|
465 |
+
* @param Api $api Api Object to use
|
466 |
+
* @return Cursor
|
467 |
+
*/
|
468 |
+
public static function readIds(array $ids, array $fields = array(), array $params = array(), \PixelCaffeine\Dependencies\FacebookAds\Api $api = null)
|
469 |
+
{
|
470 |
+
if (empty($fields)) {
|
471 |
+
$fields = static::getDefaultReadFields();
|
472 |
+
}
|
473 |
+
if (!empty($fields)) {
|
474 |
+
$params['fields'] = \implode(',', $fields);
|
475 |
+
}
|
476 |
+
$params['ids'] = \implode(',', $ids);
|
477 |
+
$api = static::assureApi($api);
|
478 |
+
$response = $api->call('/', \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, $params);
|
479 |
+
$result = array();
|
480 |
+
foreach ($response->getContent() as $data) {
|
481 |
+
/** @var AbstractObject $object */
|
482 |
+
$object = new static(null, null, $api);
|
483 |
+
$object->setDataWithoutValidation((array) $data);
|
484 |
+
$result[] = $object;
|
485 |
+
}
|
486 |
+
return $result;
|
487 |
+
}
|
488 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AbstractObject.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiConfig;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\TypeChecker;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\EmptyEnum;
|
30 |
+
class AbstractObject
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @var mixed[] set of key value pairs representing data
|
34 |
+
*/
|
35 |
+
protected $data = array();
|
36 |
+
protected $_type_checker;
|
37 |
+
public function __construct()
|
38 |
+
{
|
39 |
+
$this->data = static::getFieldsEnum()->getValuesMap();
|
40 |
+
$this->_type_checker = new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker(static::getFieldTypes(), static::getReferencedEnums());
|
41 |
+
}
|
42 |
+
protected static function getFieldTypes()
|
43 |
+
{
|
44 |
+
$fields_enum = static::getFieldsEnum();
|
45 |
+
if (\method_exists($fields_enum, 'getFieldTypes')) {
|
46 |
+
return $fields_enum->getFieldTypes();
|
47 |
+
} else {
|
48 |
+
return array();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
protected static function getReferencedEnums()
|
52 |
+
{
|
53 |
+
return array();
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* @param string $name
|
57 |
+
* @param mixed $value
|
58 |
+
*/
|
59 |
+
public function __set($name, $value)
|
60 |
+
{
|
61 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\ApiConfig::TYPE_CHECKER_STRICT_MODE && $this->_type_checker->isValidParam($name)) {
|
62 |
+
if ($this->_type_checker->isValidParamPair($name, $value)) {
|
63 |
+
$this->data[$name] = $value;
|
64 |
+
} else {
|
65 |
+
throw new \InvalidArgumentException($name . " and " . $this->exportValue($value) . " are not a valid type value pair");
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
$this->data[$name] = $value;
|
69 |
+
}
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
/**
|
73 |
+
* @param string $name
|
74 |
+
* @return mixed
|
75 |
+
* @throws \InvalidArgumentException
|
76 |
+
*/
|
77 |
+
public function __get($name)
|
78 |
+
{
|
79 |
+
if (\array_key_exists($name, $this->data)) {
|
80 |
+
return $this->data[$name];
|
81 |
+
} else {
|
82 |
+
throw new \InvalidArgumentException($name . ' is not a field of ' . \get_class($this));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* @param string $name
|
87 |
+
* @return boolean
|
88 |
+
*/
|
89 |
+
public function __isset($name)
|
90 |
+
{
|
91 |
+
return \array_key_exists($name, $this->data);
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* @param array
|
95 |
+
* @return $this
|
96 |
+
*/
|
97 |
+
public function setData(array $data)
|
98 |
+
{
|
99 |
+
foreach ($data as $key => $value) {
|
100 |
+
$this->{$key} = $value;
|
101 |
+
}
|
102 |
+
// Handle class-specific situations
|
103 |
+
if (\method_exists($this, 'setDataTrigger')) {
|
104 |
+
$this->setDataTrigger($data);
|
105 |
+
}
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
/**
|
109 |
+
* Like setData but will skip field validation
|
110 |
+
*
|
111 |
+
* @param array
|
112 |
+
* @return $this
|
113 |
+
*/
|
114 |
+
public function setDataWithoutValidation(array $data)
|
115 |
+
{
|
116 |
+
foreach ($data as $key => $value) {
|
117 |
+
$this->data[$key] = $value;
|
118 |
+
}
|
119 |
+
// Handle class-specific situations
|
120 |
+
if (\method_exists($this, 'setDataTrigger')) {
|
121 |
+
$this->setDataTrigger($data);
|
122 |
+
}
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
/**
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
public function getData()
|
129 |
+
{
|
130 |
+
return $this->data;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* @param mixed $value
|
134 |
+
* @return mixed
|
135 |
+
*/
|
136 |
+
protected function exportValue($value)
|
137 |
+
{
|
138 |
+
$result = $value;
|
139 |
+
switch (\true) {
|
140 |
+
case $value === null:
|
141 |
+
break;
|
142 |
+
case $value instanceof \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject:
|
143 |
+
$result = $value->exportData();
|
144 |
+
break;
|
145 |
+
case \is_array($value):
|
146 |
+
$result = array();
|
147 |
+
foreach ($value as $key => $sub_value) {
|
148 |
+
if ($sub_value !== null) {
|
149 |
+
$result[$key] = $this->exportValue($sub_value);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
return $result;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* @return array
|
158 |
+
*/
|
159 |
+
public function exportData()
|
160 |
+
{
|
161 |
+
return $this->exportValue($this->data);
|
162 |
+
}
|
163 |
+
/**
|
164 |
+
* @return array
|
165 |
+
*/
|
166 |
+
public function exportAllData()
|
167 |
+
{
|
168 |
+
return $this->exportValue($this->data);
|
169 |
+
}
|
170 |
+
/**
|
171 |
+
* @return EmptyEnum
|
172 |
+
*/
|
173 |
+
public static function getFieldsEnum()
|
174 |
+
{
|
175 |
+
return \PixelCaffeine\Dependencies\FacebookAds\Enum\EmptyEnum::getInstance();
|
176 |
+
}
|
177 |
+
/**
|
178 |
+
* @return array
|
179 |
+
*/
|
180 |
+
public static function getFields()
|
181 |
+
{
|
182 |
+
return static::getFieldsEnum()->getValues();
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
public static function className()
|
188 |
+
{
|
189 |
+
return \get_called_class();
|
190 |
+
}
|
191 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixel.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiRequest;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Cursor;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\TypeChecker;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelFields;
|
32 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelAutomaticMatchingFieldsValues;
|
33 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelDataUseSettingValues;
|
34 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelFirstPartyCookieStatusValues;
|
35 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelSortByValues;
|
36 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues;
|
37 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelTasksValues;
|
38 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\DACheckConnectionMethodValues;
|
39 |
+
/**
|
40 |
+
* This class is auto-generated.
|
41 |
+
*
|
42 |
+
* For any issues or feature requests related to this class, please let us know
|
43 |
+
* on github and we'll fix in our codegen framework. We'll not be able to accept
|
44 |
+
* pull request for this class.
|
45 |
+
*
|
46 |
+
*/
|
47 |
+
class AdsPixel extends \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractCrudObject
|
48 |
+
{
|
49 |
+
/**
|
50 |
+
* @deprecated getEndpoint function is deprecated
|
51 |
+
*/
|
52 |
+
protected function getEndpoint()
|
53 |
+
{
|
54 |
+
return 'adspixels';
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* @return AdsPixelFields
|
58 |
+
*/
|
59 |
+
public static function getFieldsEnum()
|
60 |
+
{
|
61 |
+
return \PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelFields::getInstance();
|
62 |
+
}
|
63 |
+
protected static function getReferencedEnums()
|
64 |
+
{
|
65 |
+
$ref_enums = array();
|
66 |
+
$ref_enums['SortBy'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelSortByValues::getInstance()->getValues();
|
67 |
+
$ref_enums['AutomaticMatchingFields'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelAutomaticMatchingFieldsValues::getInstance()->getValues();
|
68 |
+
$ref_enums['DataUseSetting'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelDataUseSettingValues::getInstance()->getValues();
|
69 |
+
$ref_enums['FirstPartyCookieStatus'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelFirstPartyCookieStatusValues::getInstance()->getValues();
|
70 |
+
$ref_enums['Tasks'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelTasksValues::getInstance()->getValues();
|
71 |
+
return $ref_enums;
|
72 |
+
}
|
73 |
+
public function getAssignedUsers(array $fields = array(), array $params = array(), $pending = \false)
|
74 |
+
{
|
75 |
+
$this->assureId();
|
76 |
+
$param_types = array('business' => 'string');
|
77 |
+
$enums = array();
|
78 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/assigned_users', new \PixelCaffeine\Dependencies\FacebookAds\Object\AssignedUser(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AssignedUser::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
79 |
+
$request->addParams($params);
|
80 |
+
$request->addFields($fields);
|
81 |
+
return $pending ? $request : $request->execute();
|
82 |
+
}
|
83 |
+
public function createAssignedUser(array $fields = array(), array $params = array(), $pending = \false)
|
84 |
+
{
|
85 |
+
$this->assureId();
|
86 |
+
$param_types = array('tasks' => 'list<tasks_enum>', 'user' => 'int');
|
87 |
+
$enums = array('tasks_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelTasksValues::getInstance()->getValues());
|
88 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, '/assigned_users', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
89 |
+
$request->addParams($params);
|
90 |
+
$request->addFields($fields);
|
91 |
+
return $pending ? $request : $request->execute();
|
92 |
+
}
|
93 |
+
public function getDaChecks(array $fields = array(), array $params = array(), $pending = \false)
|
94 |
+
{
|
95 |
+
$this->assureId();
|
96 |
+
$param_types = array('checks' => 'list<string>', 'connection_method' => 'connection_method_enum');
|
97 |
+
$enums = array('connection_method_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\DACheckConnectionMethodValues::getInstance()->getValues());
|
98 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/da_checks', new \PixelCaffeine\Dependencies\FacebookAds\Object\DACheck(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\DACheck::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
99 |
+
$request->addParams($params);
|
100 |
+
$request->addFields($fields);
|
101 |
+
return $pending ? $request : $request->execute();
|
102 |
+
}
|
103 |
+
public function createEvent(array $fields = array(), array $params = array(), $pending = \false)
|
104 |
+
{
|
105 |
+
$this->assureId();
|
106 |
+
$param_types = array('data' => 'list<string>', 'namespace_id' => 'string', 'partner_agent' => 'string', 'test_event_code' => 'string', 'trace' => 'unsigned int', 'upload_id' => 'string', 'upload_source' => 'string', 'upload_tag' => 'string');
|
107 |
+
$enums = array();
|
108 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, '/events', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
109 |
+
$request->addParams($params);
|
110 |
+
$request->addFields($fields);
|
111 |
+
return $pending ? $request : $request->execute();
|
112 |
+
}
|
113 |
+
public function createShadowTrafficHelper(array $fields = array(), array $params = array(), $pending = \false)
|
114 |
+
{
|
115 |
+
$this->assureId();
|
116 |
+
$param_types = array();
|
117 |
+
$enums = array();
|
118 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, '/shadowtraffichelper', new \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractCrudObject(), 'EDGE', array(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
119 |
+
$request->addParams($params);
|
120 |
+
$request->addFields($fields);
|
121 |
+
return $pending ? $request : $request->execute();
|
122 |
+
}
|
123 |
+
public function deleteSharedAccounts(array $fields = array(), array $params = array(), $pending = \false)
|
124 |
+
{
|
125 |
+
$this->assureId();
|
126 |
+
$param_types = array('account_id' => 'string', 'business' => 'string');
|
127 |
+
$enums = array();
|
128 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_DELETE, '/shared_accounts', new \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractCrudObject(), 'EDGE', array(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
129 |
+
$request->addParams($params);
|
130 |
+
$request->addFields($fields);
|
131 |
+
return $pending ? $request : $request->execute();
|
132 |
+
}
|
133 |
+
public function getSharedAccounts(array $fields = array(), array $params = array(), $pending = \false)
|
134 |
+
{
|
135 |
+
$this->assureId();
|
136 |
+
$param_types = array('business' => 'string');
|
137 |
+
$enums = array();
|
138 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/shared_accounts', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdAccount(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdAccount::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
139 |
+
$request->addParams($params);
|
140 |
+
$request->addFields($fields);
|
141 |
+
return $pending ? $request : $request->execute();
|
142 |
+
}
|
143 |
+
public function createSharedAccount(array $fields = array(), array $params = array(), $pending = \false)
|
144 |
+
{
|
145 |
+
$this->assureId();
|
146 |
+
$param_types = array('account_id' => 'string', 'business' => 'string');
|
147 |
+
$enums = array();
|
148 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, '/shared_accounts', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
149 |
+
$request->addParams($params);
|
150 |
+
$request->addFields($fields);
|
151 |
+
return $pending ? $request : $request->execute();
|
152 |
+
}
|
153 |
+
public function getSharedAgencies(array $fields = array(), array $params = array(), $pending = \false)
|
154 |
+
{
|
155 |
+
$this->assureId();
|
156 |
+
$param_types = array();
|
157 |
+
$enums = array();
|
158 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/shared_agencies', new \PixelCaffeine\Dependencies\FacebookAds\Object\Business(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\Business::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
159 |
+
$request->addParams($params);
|
160 |
+
$request->addFields($fields);
|
161 |
+
return $pending ? $request : $request->execute();
|
162 |
+
}
|
163 |
+
public function getStats(array $fields = array(), array $params = array(), $pending = \false)
|
164 |
+
{
|
165 |
+
$this->assureId();
|
166 |
+
$param_types = array('aggregation' => 'aggregation_enum', 'end_time' => 'datetime', 'event' => 'string', 'event_source' => 'string', 'start_time' => 'datetime');
|
167 |
+
$enums = array('aggregation_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues::getInstance()->getValues());
|
168 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/stats', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixelStatsResult(), 'EDGE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixelStatsResult::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
169 |
+
$request->addParams($params);
|
170 |
+
$request->addFields($fields);
|
171 |
+
return $pending ? $request : $request->execute();
|
172 |
+
}
|
173 |
+
public function getSelf(array $fields = array(), array $params = array(), $pending = \false)
|
174 |
+
{
|
175 |
+
$this->assureId();
|
176 |
+
$param_types = array();
|
177 |
+
$enums = array();
|
178 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_GET, '/', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel(), 'NODE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
179 |
+
$request->addParams($params);
|
180 |
+
$request->addFields($fields);
|
181 |
+
return $pending ? $request : $request->execute();
|
182 |
+
}
|
183 |
+
public function updateSelf(array $fields = array(), array $params = array(), $pending = \false)
|
184 |
+
{
|
185 |
+
$this->assureId();
|
186 |
+
$param_types = array('automatic_matching_fields' => 'list<automatic_matching_fields_enum>', 'data_use_setting' => 'data_use_setting_enum', 'enable_automatic_matching' => 'bool', 'first_party_cookie_status' => 'first_party_cookie_status_enum', 'name' => 'string', 'server_events_business_ids' => 'list<string>');
|
187 |
+
$enums = array('automatic_matching_fields_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelAutomaticMatchingFieldsValues::getInstance()->getValues(), 'data_use_setting_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelDataUseSettingValues::getInstance()->getValues(), 'first_party_cookie_status_enum' => \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelFirstPartyCookieStatusValues::getInstance()->getValues());
|
188 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\ApiRequest($this->api, $this->data['id'], \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, '/', new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel(), 'NODE', \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel::getFieldsEnum()->getValues(), new \PixelCaffeine\Dependencies\FacebookAds\TypeChecker($param_types, $enums));
|
189 |
+
$request->addParams($params);
|
190 |
+
$request->addFields($fields);
|
191 |
+
return $pending ? $request : $request->execute();
|
192 |
+
}
|
193 |
+
/**
|
194 |
+
* @param int $business_id
|
195 |
+
* @param string $account_id
|
196 |
+
*/
|
197 |
+
public function sharePixelWithAdAccount($business_id, $account_id)
|
198 |
+
{
|
199 |
+
$this->getApi()->call('/' . $this->assureId() . '/shared_accounts', \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_POST, array('business' => $business_id, 'account_id' => $account_id));
|
200 |
+
}
|
201 |
+
/**
|
202 |
+
* @param $business_id
|
203 |
+
* @param $account_id
|
204 |
+
*/
|
205 |
+
public function unsharePixelWithAdAccount($business_id, $account_id)
|
206 |
+
{
|
207 |
+
$this->getApi()->call('/' . $this->assureId() . '/shared_accounts', \PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface::METHOD_DELETE, array('business' => $business_id, 'account_id' => $account_id));
|
208 |
+
}
|
209 |
+
/**
|
210 |
+
* @param int $business_id
|
211 |
+
* @param int $agency_id
|
212 |
+
*/
|
213 |
+
public function sharePixelWithAgency($business_id, $agency_id)
|
214 |
+
{
|
215 |
+
$this->getApi()->call('/' . $this->assureId() . '/shared_agencies', 'POST', array('business' => $business_id, 'agency_id' => $agency_id));
|
216 |
+
}
|
217 |
+
/**
|
218 |
+
* @param int $business_id
|
219 |
+
* @param int $agency_id
|
220 |
+
*/
|
221 |
+
public function unsharePixelWithAgency($business_id, $agency_id)
|
222 |
+
{
|
223 |
+
$this->getApi()->call('/' . $this->assureId() . '/shared_agencies', 'DELETE', array('business' => $business_id, 'agency_id' => $agency_id));
|
224 |
+
}
|
225 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStats.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,15 +22,13 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\
|
28 |
-
use FacebookAds\
|
29 |
-
use FacebookAds\
|
30 |
-
use FacebookAds\TypeChecker;
|
31 |
-
use FacebookAds\Object\Fields\AdsPixelStatsFields;
|
32 |
-
|
33 |
/**
|
34 |
* This class is auto-generated.
|
35 |
*
|
@@ -38,20 +37,18 @@ use FacebookAds\Object\Fields\AdsPixelStatsFields;
|
|
38 |
* pull request for this class.
|
39 |
*
|
40 |
*/
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiRequest;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Cursor;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\TypeChecker;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelStatsFields;
|
|
|
|
|
|
|
32 |
/**
|
33 |
* This class is auto-generated.
|
34 |
*
|
37 |
* pull request for this class.
|
38 |
*
|
39 |
*/
|
40 |
+
class AdsPixelStats extends \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* @return AdsPixelStatsFields
|
44 |
+
*/
|
45 |
+
public static function getFieldsEnum()
|
46 |
+
{
|
47 |
+
return \PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelStatsFields::getInstance();
|
48 |
+
}
|
49 |
+
protected static function getReferencedEnums()
|
50 |
+
{
|
51 |
+
$ref_enums = array();
|
52 |
+
return $ref_enums;
|
53 |
+
}
|
|
|
|
|
54 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/AdsPixelStatsResult.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,16 +22,14 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\
|
28 |
-
use FacebookAds\
|
29 |
-
use FacebookAds\
|
30 |
-
use FacebookAds\
|
31 |
-
use FacebookAds\Object\
|
32 |
-
use FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues;
|
33 |
-
|
34 |
/**
|
35 |
* This class is auto-generated.
|
36 |
*
|
@@ -39,28 +38,26 @@ use FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues;
|
|
39 |
* pull request for this class.
|
40 |
*
|
41 |
*/
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiRequest;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Cursor;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\RequestInterface;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\TypeChecker;
|
31 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelStatsResultFields;
|
32 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues;
|
|
|
|
|
33 |
/**
|
34 |
* This class is auto-generated.
|
35 |
*
|
38 |
* pull request for this class.
|
39 |
*
|
40 |
*/
|
41 |
+
class AdsPixelStatsResult extends \PixelCaffeine\Dependencies\FacebookAds\Object\AbstractObject
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* @deprecated getEndpoint function is deprecated
|
45 |
+
*/
|
46 |
+
protected function getEndpoint()
|
47 |
+
{
|
48 |
+
return 'stats';
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* @return AdsPixelStatsResultFields
|
52 |
+
*/
|
53 |
+
public static function getFieldsEnum()
|
54 |
+
{
|
55 |
+
return \PixelCaffeine\Dependencies\FacebookAds\Object\Fields\AdsPixelStatsResultFields::getInstance();
|
56 |
+
}
|
57 |
+
protected static function getReferencedEnums()
|
58 |
+
{
|
59 |
+
$ref_enums = array();
|
60 |
+
$ref_enums['Aggregation'] = \PixelCaffeine\Dependencies\FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues::getInstance()->getValues();
|
61 |
+
return $ref_enums;
|
62 |
+
}
|
|
|
|
|
63 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AbstractArchivableCrudObjectFields.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,13 +22,11 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
const CONFIGURED_STATUS = 'configured_status';
|
32 |
-
const EFFECTIVE_STATUS = 'effective_status';
|
33 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Fields;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
28 |
+
abstract class AbstractArchivableCrudObjectFields extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
29 |
+
{
|
30 |
+
const CONFIGURED_STATUS = 'configured_status';
|
31 |
+
const EFFECTIVE_STATUS = 'effective_status';
|
|
|
|
|
|
|
32 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelFields.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Fields;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
28 |
+
/**
|
29 |
+
* This class is auto-generated.
|
30 |
+
*
|
31 |
+
* For any issues or feature requests related to this class, please let us know
|
32 |
+
* on github and we'll fix in our codegen framework. We'll not be able to accept
|
33 |
+
* pull request for this class.
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
class AdsPixelFields extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
37 |
+
{
|
38 |
+
const AUTOMATIC_MATCHING_FIELDS = 'automatic_matching_fields';
|
39 |
+
const CAN_PROXY = 'can_proxy';
|
40 |
+
const CODE = 'code';
|
41 |
+
const CREATION_TIME = 'creation_time';
|
42 |
+
const CREATOR = 'creator';
|
43 |
+
const DATA_USE_SETTING = 'data_use_setting';
|
44 |
+
const ENABLE_AUTOMATIC_MATCHING = 'enable_automatic_matching';
|
45 |
+
const FIRST_PARTY_COOKIE_STATUS = 'first_party_cookie_status';
|
46 |
+
const ID = 'id';
|
47 |
+
const IS_CREATED_BY_BUSINESS = 'is_created_by_business';
|
48 |
+
const IS_UNAVAILABLE = 'is_unavailable';
|
49 |
+
const LAST_FIRED_TIME = 'last_fired_time';
|
50 |
+
const NAME = 'name';
|
51 |
+
const OWNER_AD_ACCOUNT = 'owner_ad_account';
|
52 |
+
const OWNER_BUSINESS = 'owner_business';
|
53 |
+
public function getFieldTypes()
|
54 |
+
{
|
55 |
+
return array('automatic_matching_fields' => 'list<string>', 'can_proxy' => 'bool', 'code' => 'string', 'creation_time' => 'datetime', 'creator' => 'User', 'data_use_setting' => 'string', 'enable_automatic_matching' => 'bool', 'first_party_cookie_status' => 'string', 'id' => 'string', 'is_created_by_business' => 'bool', 'is_unavailable' => 'bool', 'last_fired_time' => 'datetime', 'name' => 'string', 'owner_ad_account' => 'AdAccount', 'owner_business' => 'Business');
|
56 |
+
}
|
57 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsFields.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -34,20 +33,14 @@ use FacebookAds\Enum\AbstractEnum;
|
|
34 |
* pull request for this class.
|
35 |
*
|
36 |
*/
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
'count' => 'int',
|
48 |
-
'diagnostics_hourly_last_timestamp' => 'datetime',
|
49 |
-
'event' => 'string',
|
50 |
-
'value' => 'string',
|
51 |
-
);
|
52 |
-
}
|
53 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Fields;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
33 |
* pull request for this class.
|
34 |
*
|
35 |
*/
|
36 |
+
class AdsPixelStatsFields extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
37 |
+
{
|
38 |
+
const COUNT = 'count';
|
39 |
+
const DIAGNOSTICS_HOURLY_LAST_TIMESTAMP = 'diagnostics_hourly_last_timestamp';
|
40 |
+
const EVENT = 'event';
|
41 |
+
const VALUE = 'value';
|
42 |
+
public function getFieldTypes()
|
43 |
+
{
|
44 |
+
return array('count' => 'int', 'diagnostics_hourly_last_timestamp' => 'datetime', 'event' => 'string', 'value' => 'string');
|
45 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Fields/AdsPixelStatsResultFields.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -34,18 +33,13 @@ use FacebookAds\Enum\AbstractEnum;
|
|
34 |
* pull request for this class.
|
35 |
*
|
36 |
*/
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
'aggregation' => 'string',
|
47 |
-
'data' => 'list<AdsPixelStats>',
|
48 |
-
'start_time' => 'datetime',
|
49 |
-
);
|
50 |
-
}
|
51 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Fields;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
33 |
* pull request for this class.
|
34 |
*
|
35 |
*/
|
36 |
+
class AdsPixelStatsResultFields extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
37 |
+
{
|
38 |
+
const AGGREGATION = 'aggregation';
|
39 |
+
const DATA = 'data';
|
40 |
+
const START_TIME = 'start_time';
|
41 |
+
public function getFieldTypes()
|
42 |
+
{
|
43 |
+
return array('aggregation' => 'string', 'data' => 'list<AdsPixelStats>', 'start_time' => 'datetime');
|
44 |
+
}
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/ActionSource.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* Class ActionSource
|
31 |
*
|
@@ -33,45 +32,38 @@ use FacebookAds\Enum\AbstractEnum;
|
|
33 |
*
|
34 |
* @package FacebookAds\Object\ServerSide
|
35 |
*/
|
36 |
-
class ActionSource extends AbstractEnum
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*/
|
71 |
-
const SYSTEM_GENERATED = 'system_generated';
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Conversion happened in a way that is not listed.
|
75 |
-
*/
|
76 |
-
const OTHER = 'other';
|
77 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* Class ActionSource
|
30 |
*
|
32 |
*
|
33 |
* @package FacebookAds\Object\ServerSide
|
34 |
*/
|
35 |
+
class ActionSource extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Conversion happened over email.
|
39 |
+
*/
|
40 |
+
const EMAIL = 'email';
|
41 |
+
/**
|
42 |
+
* Conversion was made on your website.
|
43 |
+
*/
|
44 |
+
const WEBSITE = 'website';
|
45 |
+
/**
|
46 |
+
* Conversion was made using your app.
|
47 |
+
*/
|
48 |
+
const APP = 'app';
|
49 |
+
/**
|
50 |
+
* Conversion was made over the phone.
|
51 |
+
*/
|
52 |
+
const PHONE_CALL = 'phone_call';
|
53 |
+
/**
|
54 |
+
* Conversion was made via a messaging app, SMS, or online messaging feature.
|
55 |
+
*/
|
56 |
+
const CHAT = 'chat';
|
57 |
+
/**
|
58 |
+
* Conversion was made in person at your physical store.
|
59 |
+
*/
|
60 |
+
const PHYSICAL_STORE = 'physical_store';
|
61 |
+
/**
|
62 |
+
* Conversion happened automatically, for example, a subscription renewal that’s set on auto-pay each month.
|
63 |
+
*/
|
64 |
+
const SYSTEM_GENERATED = 'system_generated';
|
65 |
+
/**
|
66 |
+
* Conversion happened in a way that is not listed.
|
67 |
+
*/
|
68 |
+
const OTHER = 'other';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\SimpleRequest;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Exception\Exception;
|
30 |
+
use ArrayAccess;
|
31 |
+
class AdsPixelSettings implements \ArrayAccess
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
const SIGNALS_JSON_CONFIG_PATH = 'signals/config/json';
|
37 |
+
/**
|
38 |
+
* Associative array for storing property values
|
39 |
+
* @var mixed[]
|
40 |
+
*/
|
41 |
+
protected $container = array();
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
* @param mixed[] $data Associated array of property value initializing the model
|
45 |
+
*/
|
46 |
+
public function __construct(array $data = null)
|
47 |
+
{
|
48 |
+
$this->container['enable_automatic_matching'] = isset($data['enableAutomaticMatching']) ? $data['enableAutomaticMatching'] : null;
|
49 |
+
$this->container['enabled_automatic_matching_fields'] = isset($data['enabledAutomaticMatchingFields']) ? $data['enabledAutomaticMatchingFields'] : null;
|
50 |
+
$this->container['pixel_id'] = isset($data['pixel_id']) ? $data['pixel_id'] : null;
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* Factory method to build the settings given a pixel id
|
54 |
+
* @param string $pixelId
|
55 |
+
* @return AdsPixelId
|
56 |
+
*/
|
57 |
+
public static function buildFromPixelId($pixelId)
|
58 |
+
{
|
59 |
+
$response = self::callPixelSettingsEndpoint($pixelId);
|
60 |
+
if ($response !== null) {
|
61 |
+
$jsonString = $response->getBody();
|
62 |
+
$pixelSettingsAsDict = \json_decode($jsonString, \true);
|
63 |
+
if (\array_key_exists('errorMessage', $pixelSettingsAsDict)) {
|
64 |
+
return null;
|
65 |
+
}
|
66 |
+
$pixelSettingsAsDict['matchingConfig']['pixel_id'] = $pixelId;
|
67 |
+
return new \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\AdsPixelSettings($pixelSettingsAsDict['matchingConfig']);
|
68 |
+
}
|
69 |
+
return null;
|
70 |
+
}
|
71 |
+
/**
|
72 |
+
* @param string $pixelId
|
73 |
+
* @return SimpleRequest
|
74 |
+
*/
|
75 |
+
private static function callPixelSettingsEndpoint($pixelId)
|
76 |
+
{
|
77 |
+
$path = \sprintf("%s/%s/", self::SIGNALS_JSON_CONFIG_PATH, $pixelId);
|
78 |
+
$client = new \PixelCaffeine\Dependencies\FacebookAds\Http\Client();
|
79 |
+
$request = new \PixelCaffeine\Dependencies\FacebookAds\Http\SimpleRequest($client);
|
80 |
+
$request->setPath($path);
|
81 |
+
try {
|
82 |
+
return $client->sendRequest($request);
|
83 |
+
} catch (\PixelCaffeine\Dependencies\FacebookAds\Exception\Exception $e) {
|
84 |
+
return null;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* Get Pixel Id.
|
89 |
+
* @return string pixel id
|
90 |
+
*/
|
91 |
+
public function getPixelId()
|
92 |
+
{
|
93 |
+
return $this->container['pixel_id'];
|
94 |
+
}
|
95 |
+
/**
|
96 |
+
* Sets Pixel id.
|
97 |
+
* @param string $pixelId
|
98 |
+
* @return $this
|
99 |
+
*/
|
100 |
+
public function setPixelId($pixelId)
|
101 |
+
{
|
102 |
+
$this->container['pixel_id'] = $pixelId;
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
/**
|
106 |
+
* Get Enable automatic matching.
|
107 |
+
* @return bool enable automatic matching
|
108 |
+
*/
|
109 |
+
public function getEnableAutomaticMatching()
|
110 |
+
{
|
111 |
+
return $this->container['enable_automatic_matching'];
|
112 |
+
}
|
113 |
+
/**
|
114 |
+
* Sets Enable automatic matching.
|
115 |
+
* @param bool $enableAutomaticMatching
|
116 |
+
* @return $this
|
117 |
+
*/
|
118 |
+
public function setEnableAutomaticMatching($enableAutomaticMatching)
|
119 |
+
{
|
120 |
+
$this->container['enable_automatic_matching'] = $enableAutomaticMatching;
|
121 |
+
return $this;
|
122 |
+
}
|
123 |
+
/**
|
124 |
+
* Get Enabled automatic matching fields.
|
125 |
+
* @return array enabled automatic matching fields
|
126 |
+
*/
|
127 |
+
public function getEnabledAutomaticMatchingFields()
|
128 |
+
{
|
129 |
+
return $this->container['enabled_automatic_matching_fields'];
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* Sets Enabled automatic matching fields.
|
133 |
+
* @param array $enabledAutomaticMatchingFields
|
134 |
+
* @return $this
|
135 |
+
*/
|
136 |
+
public function setEnabledAutomaticMatchingFields($enabledAutomaticMatchingFields)
|
137 |
+
{
|
138 |
+
$this->container['enabled_automatic_matching_fields'] = $enabledAutomaticMatchingFields;
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
/**
|
142 |
+
* Returns true if offset exists. False otherwise.
|
143 |
+
* @param integer $offset Offset
|
144 |
+
* @return boolean
|
145 |
+
*/
|
146 |
+
public function offsetExists($offset)
|
147 |
+
{
|
148 |
+
return isset($this->container[$offset]);
|
149 |
+
}
|
150 |
+
/**
|
151 |
+
* Gets offset.
|
152 |
+
* @param integer $offset Offset
|
153 |
+
* @return mixed
|
154 |
+
*/
|
155 |
+
public function offsetGet($offset)
|
156 |
+
{
|
157 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
158 |
+
}
|
159 |
+
/**
|
160 |
+
* Sets value based on offset.
|
161 |
+
* @param integer $offset Offset
|
162 |
+
* @param mixed $value Value to be set
|
163 |
+
* @return void
|
164 |
+
*/
|
165 |
+
public function offsetSet($offset, $value)
|
166 |
+
{
|
167 |
+
if (\is_null($offset)) {
|
168 |
+
$this->container[] = $value;
|
169 |
+
} else {
|
170 |
+
$this->container[$offset] = $value;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
/**
|
174 |
+
* Unsets offset.
|
175 |
+
* @param integer $offset Offset
|
176 |
+
* @return void
|
177 |
+
*/
|
178 |
+
public function offsetUnset($offset)
|
179 |
+
{
|
180 |
+
unset($this->container[$offset]);
|
181 |
+
}
|
182 |
+
/**
|
183 |
+
* Gets the string presentation of the object
|
184 |
+
* @return string
|
185 |
+
*/
|
186 |
+
public function __toString()
|
187 |
+
{
|
188 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
189 |
+
// use JSON pretty print
|
190 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
191 |
+
}
|
192 |
+
return \json_encode($this);
|
193 |
+
}
|
194 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AsyncClient.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,33 +22,22 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
CURLOPT_RETURNTRANSFER => true,
|
42 |
-
CURLOPT_HEADER => true,
|
43 |
-
CURLOPT_CAINFO => Api::instance()->getHttpClient()->getCaBundlePath(),
|
44 |
-
]
|
45 |
-
]));
|
46 |
-
|
47 |
-
$this->client = new Client(['handler' => $handler_stack]);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getClient() {
|
51 |
-
return $this->client;
|
52 |
-
}
|
53 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
28 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Client;
|
29 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\HandlerStack;
|
30 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlHandler;
|
31 |
+
class AsyncClient extends \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Singleton
|
32 |
+
{
|
33 |
+
protected $client = null;
|
34 |
+
public function __construct()
|
35 |
+
{
|
36 |
+
$handler_stack = \PixelCaffeine\Dependencies\GuzzleHttp\HandlerStack::create(new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlHandler(['options' => [\CURLOPT_CONNECTTIMEOUT => 10, \CURLOPT_TIMEOUT => 60, \CURLOPT_RETURNTRANSFER => \true, \CURLOPT_HEADER => \true, \CURLOPT_CAINFO => \PixelCaffeine\Dependencies\FacebookAds\Api::instance()->getHttpClient()->getCaBundlePath()]]));
|
37 |
+
$this->client = new \PixelCaffeine\Dependencies\GuzzleHttp\Client(['handler' => $handler_stack]);
|
38 |
+
}
|
39 |
+
public function getClient()
|
40 |
+
{
|
41 |
+
return $this->client;
|
42 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/BatchProcessor.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
28 |
+
class BatchProcessor
|
29 |
+
{
|
30 |
+
protected $batch_size;
|
31 |
+
protected $concurrent_requests;
|
32 |
+
protected $pixel_id;
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
* @param int $pixel_id
|
36 |
+
* @param int $batch_size
|
37 |
+
* @param int $concurrent_requests
|
38 |
+
*/
|
39 |
+
public function __construct($pixel_id, $batch_size = 50, $concurrent_requests = 4)
|
40 |
+
{
|
41 |
+
$this->pixel_id = $pixel_id;
|
42 |
+
// Note: batch_size is only used in processEvents and processEventsGenerator
|
43 |
+
$this->batch_size = $batch_size;
|
44 |
+
$this->concurrent_requests = $concurrent_requests;
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* Processes events that have identical event_request params
|
48 |
+
* @param array $event_request_params
|
49 |
+
* @param array|\FacebookAds\Object\ServerSide\Event $events
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
public function processEvents($event_request_params, $events)
|
53 |
+
{
|
54 |
+
$generator = $this->processEventsGenerator($event_request_params, $events);
|
55 |
+
foreach ($generator as $promises) {
|
56 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Promise\unwrap($promises);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
/**
|
60 |
+
* This generator returns event_requests promises for events that have identical event_request params
|
61 |
+
* @param array $event_request_params
|
62 |
+
* @param array|\FacebookAds\Object\ServerSide\Event $events
|
63 |
+
* @return Generator|array|\GuzzleHttp\Promise\PromiseInterface $promises
|
64 |
+
*/
|
65 |
+
public function processEventsGenerator($event_request_params, $events)
|
66 |
+
{
|
67 |
+
$index = 0;
|
68 |
+
while ($index < \count($events)) {
|
69 |
+
$promises = [];
|
70 |
+
while ($index < \count($events) && \count($promises) < $this->concurrent_requests) {
|
71 |
+
$params = \array_merge(array('events' => \array_slice($events, $index, $this->batch_size)), $event_request_params);
|
72 |
+
$event_request = new \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\EventRequestAsync($this->pixel_id, $params);
|
73 |
+
$promises[] = $event_request->execute();
|
74 |
+
$index += $this->batch_size;
|
75 |
+
}
|
76 |
+
(yield $promises);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
* Processes async event_requests
|
81 |
+
* @param array|\FacebookAds\Object\ServerSide\EventRequestAsync $event_requests_async
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function processEventRequests($event_requests_async)
|
85 |
+
{
|
86 |
+
$generator = $this->processEventRequestsGenerator($event_requests_async);
|
87 |
+
foreach ($generator as $promises) {
|
88 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Promise\unwrap($promises);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* This generator returns event_requests promises
|
93 |
+
* @param array|\FacebookAds\Object\ServerSide\EventRequestAsync $event_requests_async
|
94 |
+
* @return Generator|array|\GuzzleHttp\Promise\PromiseInterface $promises
|
95 |
+
*/
|
96 |
+
public function processEventRequestsGenerator($event_requests_async)
|
97 |
+
{
|
98 |
+
$index = 0;
|
99 |
+
while ($index < \count($event_requests_async)) {
|
100 |
+
$promises = [];
|
101 |
+
$offset = 0;
|
102 |
+
while ($index + $offset < \count($event_requests_async) && \count($promises) < $this->concurrent_requests) {
|
103 |
+
$promises[] = $event_requests_async[$index + $offset]->execute();
|
104 |
+
$offset += 1;
|
105 |
+
}
|
106 |
+
$index += $offset;
|
107 |
+
(yield $promises);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Content.php
ADDED
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
class Content implements \ArrayAccess
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* Associative array for storing property values
|
32 |
+
* @var mixed[]
|
33 |
+
*/
|
34 |
+
protected $container = array();
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
* @param mixed[] $data Associated array of property value initializing the model
|
38 |
+
*/
|
39 |
+
public function __construct(array $data = null)
|
40 |
+
{
|
41 |
+
$this->container['product_id'] = isset($data['product_id']) ? $data['product_id'] : null;
|
42 |
+
$this->container['quantity'] = isset($data['quantity']) ? $data['quantity'] : null;
|
43 |
+
$this->container['item_price'] = isset($data['item_price']) ? $data['item_price'] : null;
|
44 |
+
$this->container['title'] = isset($data['title']) ? $data['title'] : null;
|
45 |
+
$this->container['description'] = isset($data['description']) ? $data['description'] : null;
|
46 |
+
$this->container['brand'] = isset($data['brand']) ? $data['brand'] : null;
|
47 |
+
$this->container['category'] = isset($data['category']) ? $data['category'] : null;
|
48 |
+
$this->container['delivery_category'] = isset($data['delivery_category']) ? $data['delivery_category'] : null;
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* Get Product Id.
|
52 |
+
* @return string Product Id
|
53 |
+
*/
|
54 |
+
public function getProductId()
|
55 |
+
{
|
56 |
+
return $this->container['product_id'];
|
57 |
+
}
|
58 |
+
/**
|
59 |
+
* Sets product id.
|
60 |
+
* @param string $product_id product id
|
61 |
+
* @return $this
|
62 |
+
*/
|
63 |
+
public function setProductId($product_id)
|
64 |
+
{
|
65 |
+
$this->container['product_id'] = $product_id;
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* Get number of product.
|
70 |
+
* @return integer quantity
|
71 |
+
*/
|
72 |
+
public function getQuantity()
|
73 |
+
{
|
74 |
+
return $this->container['quantity'];
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* Set number of product.
|
78 |
+
* @param integer $quantity number of items
|
79 |
+
* @return $this
|
80 |
+
*/
|
81 |
+
public function setQuantity($quantity)
|
82 |
+
{
|
83 |
+
$this->container['quantity'] = $quantity;
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* Get Item Price.
|
88 |
+
* @return float Item Price
|
89 |
+
*/
|
90 |
+
public function getItemPrice()
|
91 |
+
{
|
92 |
+
return $this->container['item_price'];
|
93 |
+
}
|
94 |
+
/**
|
95 |
+
* Set Item Price.
|
96 |
+
* @param float $item_price single item price
|
97 |
+
* @return Content
|
98 |
+
*/
|
99 |
+
public function setItemPrice($item_price)
|
100 |
+
{
|
101 |
+
$this->container['item_price'] = $item_price;
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Get title.
|
106 |
+
* @return string title
|
107 |
+
*/
|
108 |
+
public function getTitle()
|
109 |
+
{
|
110 |
+
return $this->container['title'];
|
111 |
+
}
|
112 |
+
/**
|
113 |
+
* Sets title.
|
114 |
+
* @param string $title title
|
115 |
+
* @return $this
|
116 |
+
*/
|
117 |
+
public function setTitle($title)
|
118 |
+
{
|
119 |
+
$this->container['title'] = $title;
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* Get description.
|
124 |
+
* @return string description
|
125 |
+
*/
|
126 |
+
public function getDescription()
|
127 |
+
{
|
128 |
+
return $this->container['description'];
|
129 |
+
}
|
130 |
+
/**
|
131 |
+
* Sets description.
|
132 |
+
* @param string $description description
|
133 |
+
* @return $this
|
134 |
+
*/
|
135 |
+
public function setDescription($description)
|
136 |
+
{
|
137 |
+
$this->container['description'] = $description;
|
138 |
+
return $this;
|
139 |
+
}
|
140 |
+
/**
|
141 |
+
* Get brand.
|
142 |
+
* @return string brand
|
143 |
+
*/
|
144 |
+
public function getBrand()
|
145 |
+
{
|
146 |
+
return $this->container['brand'];
|
147 |
+
}
|
148 |
+
/**
|
149 |
+
* Sets brand.
|
150 |
+
* @param string $brand brand
|
151 |
+
* @return $this
|
152 |
+
*/
|
153 |
+
public function setBrand($brand)
|
154 |
+
{
|
155 |
+
$this->container['brand'] = $brand;
|
156 |
+
return $this;
|
157 |
+
}
|
158 |
+
/**
|
159 |
+
* Get category.
|
160 |
+
* @return string category
|
161 |
+
*/
|
162 |
+
public function getCategory()
|
163 |
+
{
|
164 |
+
return $this->container['category'];
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* Sets category.
|
168 |
+
* @param string $category category
|
169 |
+
* @return $this
|
170 |
+
*/
|
171 |
+
public function setCategory($category)
|
172 |
+
{
|
173 |
+
$this->container['category'] = $category;
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
/**
|
177 |
+
* Gets Type of delivery for a purchase event.
|
178 |
+
* @return string delivery_category
|
179 |
+
*/
|
180 |
+
public function getDeliveryCategory()
|
181 |
+
{
|
182 |
+
return $this->container['delivery_category'];
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* Sets Type of delivery for a purchase event.
|
186 |
+
* @param string $delivery_category
|
187 |
+
* @return $this
|
188 |
+
*/
|
189 |
+
public function setDeliveryCategory($delivery_category)
|
190 |
+
{
|
191 |
+
$this->container['delivery_category'] = $delivery_category;
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
/**
|
195 |
+
* Returns true if offset exists. False otherwise.
|
196 |
+
* @param integer $offset Offset
|
197 |
+
* @return boolean
|
198 |
+
*/
|
199 |
+
public function offsetExists($offset)
|
200 |
+
{
|
201 |
+
return isset($this->container[$offset]);
|
202 |
+
}
|
203 |
+
/**
|
204 |
+
* Gets offset.
|
205 |
+
* @param integer $offset Offset
|
206 |
+
* @return mixed
|
207 |
+
*/
|
208 |
+
public function offsetGet($offset)
|
209 |
+
{
|
210 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
211 |
+
}
|
212 |
+
/**
|
213 |
+
* Sets value based on offset.
|
214 |
+
* @param integer $offset Offset
|
215 |
+
* @param mixed $value Value to be set
|
216 |
+
* @return void
|
217 |
+
*/
|
218 |
+
public function offsetSet($offset, $value)
|
219 |
+
{
|
220 |
+
if (\is_null($offset)) {
|
221 |
+
$this->container[] = $value;
|
222 |
+
} else {
|
223 |
+
$this->container[$offset] = $value;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
/**
|
227 |
+
* Unsets offset.
|
228 |
+
* @param integer $offset Offset
|
229 |
+
* @return void
|
230 |
+
*/
|
231 |
+
public function offsetUnset($offset)
|
232 |
+
{
|
233 |
+
unset($this->container[$offset]);
|
234 |
+
}
|
235 |
+
/**
|
236 |
+
* Gets the string presentation of the object
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
public function __toString()
|
240 |
+
{
|
241 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
242 |
+
// use JSON pretty print
|
243 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
244 |
+
}
|
245 |
+
return \json_encode($this);
|
246 |
+
}
|
247 |
+
/**
|
248 |
+
* Normalize
|
249 |
+
* @return array
|
250 |
+
*/
|
251 |
+
public function normalize()
|
252 |
+
{
|
253 |
+
$normalized_payload = array('id' => $this->container['product_id'], 'quantity' => $this->container['quantity'], 'item_price' => $this->container['item_price'], 'title' => $this->container['title'], 'description' => $this->container['description'], 'brand' => $this->container['brand'], 'category' => $this->container['category'], 'delivery_category' => \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('delivery_category', $this->container['delivery_category']));
|
254 |
+
$normalized_payload = \array_filter($normalized_payload);
|
255 |
+
return $normalized_payload;
|
256 |
+
}
|
257 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/CustomData.php
ADDED
@@ -0,0 +1,514 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
use InvalidArgumentException;
|
29 |
+
class CustomData implements \ArrayAccess
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* Array of property to type mappings. Used for (de)serialization
|
33 |
+
* @var string[]
|
34 |
+
*/
|
35 |
+
protected static $param_types = array('value' => 'float', 'currency' => 'string', 'content_name' => 'string', 'content_category' => 'string', 'content_ids' => 'string[]', 'contents' => 'object[]', 'content_type' => 'string', 'order_id' => 'string', 'predicted_ltv' => 'float', 'num_items' => 'string', 'status' => 'string', 'search_string' => 'string', 'item_number' => 'string', 'delivery_category' => 'string', 'custom_properties' => 'array');
|
36 |
+
/**
|
37 |
+
* Array of attributes where the key is the local name, and the value is the original name
|
38 |
+
* @var string[]
|
39 |
+
*/
|
40 |
+
protected static $attributeMap = array('value' => 'value', 'currency' => 'currency', 'content_name' => 'content_name', 'content_category' => 'content_category', 'content_ids' => 'content_ids', 'contents' => 'contents', 'content_type' => 'content_type', 'order_id' => 'order_id', 'predicted_ltv' => 'predicted_ltv', 'num_items' => 'num_items', 'status' => 'status', 'search_string' => 'search_string', 'item_number' => 'item_number', 'delivery_category' => 'delivery_category', 'custom_properties' => 'custom_properties');
|
41 |
+
/**
|
42 |
+
* Array of attributes to setter functions (for deserialization of responses)
|
43 |
+
* @var string[]
|
44 |
+
*/
|
45 |
+
protected static $setters = array('value' => 'setValue', 'currency' => 'setCurrency', 'content_name' => 'setContentName', 'content_category' => 'setContentCategory', 'content_ids' => 'setContentIds', 'contents' => 'setContents', 'content_type' => 'setContentType', 'order_id' => 'setOrderId', 'predicted_ltv' => 'setPredictedLtv', 'num_items' => 'setNumItems', 'status' => 'setStatus', 'search_string' => 'setSearchString', 'item_number' => 'setItemNumber', 'delivery_category' => 'setDeliveryCategory', 'custom_properties' => 'setCustomProperties');
|
46 |
+
/**
|
47 |
+
* Array of attributes to getter functions (for serialization of requests)
|
48 |
+
* @var string[]
|
49 |
+
*/
|
50 |
+
protected static $getters = array('value' => 'getValue', 'currency' => 'getCurrency', 'content_name' => 'getContentName', 'content_category' => 'getContentCategory', 'content_ids' => 'getContentIds', 'contents' => 'getContents', 'content_type' => 'getContentType', 'order_id' => 'getOrderId', 'predicted_ltv' => 'getPredictedLtv', 'num_items' => 'getNumItems', 'status' => 'getStatus', 'search_string' => 'getSearchString', 'item_number' => 'getItemNumber', 'delivery_category' => 'getDeliveryCategory', 'custom_properties' => 'getCustomProperties');
|
51 |
+
/**
|
52 |
+
* Associative array for storing property values
|
53 |
+
* @var mixed[]
|
54 |
+
*/
|
55 |
+
protected $container = array();
|
56 |
+
/**
|
57 |
+
* Constructor
|
58 |
+
* @param mixed[] $data Associated array of property value initializing the model
|
59 |
+
*/
|
60 |
+
public function __construct(array $data = null)
|
61 |
+
{
|
62 |
+
$this->container['value'] = isset($data['value']) ? $data['value'] : null;
|
63 |
+
$this->container['currency'] = isset($data['currency']) ? $data['currency'] : null;
|
64 |
+
$this->container['content_name'] = isset($data['content_name']) ? $data['content_name'] : null;
|
65 |
+
$this->container['content_category'] = isset($data['content_category']) ? $data['content_category'] : null;
|
66 |
+
$this->container['content_ids'] = isset($data['content_ids']) ? $data['content_ids'] : null;
|
67 |
+
$this->container['contents'] = isset($data['contents']) ? $data['contents'] : null;
|
68 |
+
$this->container['content_type'] = isset($data['content_type']) ? $data['content_type'] : null;
|
69 |
+
$this->container['order_id'] = isset($data['order_id']) ? $data['order_id'] : null;
|
70 |
+
$this->container['predicted_ltv'] = isset($data['predicted_ltv']) ? $data['predicted_ltv'] : null;
|
71 |
+
$this->container['num_items'] = isset($data['num_items']) ? $data['num_items'] : null;
|
72 |
+
$this->container['status'] = isset($data['status']) ? $data['status'] : null;
|
73 |
+
$this->container['search_string'] = isset($data['search_string']) ? $data['search_string'] : null;
|
74 |
+
$this->container['item_number'] = isset($data['item_number']) ? $data['item_number'] : null;
|
75 |
+
$this->container['delivery_category'] = isset($data['delivery_category']) ? $data['delivery_category'] : null;
|
76 |
+
$this->container['custom_properties'] = isset($data['custom_properties']) ? $data['custom_properties'] : null;
|
77 |
+
}
|
78 |
+
public static function paramTypes()
|
79 |
+
{
|
80 |
+
return self::$param_types;
|
81 |
+
}
|
82 |
+
public static function attributeMap()
|
83 |
+
{
|
84 |
+
return self::$attributeMap;
|
85 |
+
}
|
86 |
+
public static function setters()
|
87 |
+
{
|
88 |
+
return self::$setters;
|
89 |
+
}
|
90 |
+
public static function getters()
|
91 |
+
{
|
92 |
+
return self::$getters;
|
93 |
+
}
|
94 |
+
/**
|
95 |
+
* show all the invalid properties with reasons.
|
96 |
+
*
|
97 |
+
* @return array invalid properties with reasons
|
98 |
+
*/
|
99 |
+
public function listInvalidProperties()
|
100 |
+
{
|
101 |
+
$invalid_properties = array();
|
102 |
+
return $invalid_properties;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* validate all the properties in the model
|
106 |
+
* return true if all passed
|
107 |
+
*
|
108 |
+
* @return bool True if all properteis are valid
|
109 |
+
*/
|
110 |
+
public function valid()
|
111 |
+
{
|
112 |
+
return \true;
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* Sets value
|
116 |
+
* @param float $value A numeric value associated with this event.
|
117 |
+
* This could be a monetary value or a value in some other metric.
|
118 |
+
* @return $this
|
119 |
+
*/
|
120 |
+
public function setValue($value)
|
121 |
+
{
|
122 |
+
$this->container['value'] = $value;
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
/**
|
126 |
+
* Sets currency
|
127 |
+
* @param string $currency The currency for the value specified, if applicable.
|
128 |
+
* Currency must be a valid ISO 4217 three digit currency code.
|
129 |
+
* @return $this
|
130 |
+
*/
|
131 |
+
public function setCurrency($currency)
|
132 |
+
{
|
133 |
+
$this->container['currency'] = $currency;
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
/**
|
137 |
+
* Sets content_name
|
138 |
+
* @param string $content_name The name of the page or product associated with the event. Example: 'lettuce'.
|
139 |
+
* @return $this
|
140 |
+
*/
|
141 |
+
public function setContentName($content_name)
|
142 |
+
{
|
143 |
+
$this->container['content_name'] = $content_name;
|
144 |
+
return $this;
|
145 |
+
}
|
146 |
+
/**
|
147 |
+
* Sets content_category
|
148 |
+
* @param string $content_category The category of the content associated with the event. Example: 'grocery'
|
149 |
+
* @return $this
|
150 |
+
*/
|
151 |
+
public function setContentCategory($content_category)
|
152 |
+
{
|
153 |
+
$this->container['content_category'] = $content_category;
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* Sets content_ids
|
158 |
+
* @param string[] $content_ids The content IDs associated with the event,
|
159 |
+
* such as product SKUs for items in an AddToCart event: ['ABC123', 'XYZ789'].
|
160 |
+
* If content_type is a product, then your content IDs must be an array with a single string value.
|
161 |
+
* Otherwise, this array can contain any number of string values.
|
162 |
+
* @return $this
|
163 |
+
*/
|
164 |
+
public function setContentIds($content_ids)
|
165 |
+
{
|
166 |
+
$this->container['content_ids'] = $content_ids;
|
167 |
+
return $this;
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* Sets contents
|
171 |
+
* @param Content[] $contents A list of Content objects that contain the product IDs associated with
|
172 |
+
* the event plus information about the products.
|
173 |
+
* @return $this
|
174 |
+
*/
|
175 |
+
public function setContents($contents)
|
176 |
+
{
|
177 |
+
$this->container['contents'] = $contents;
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* Sets content_type
|
182 |
+
* @param string $content_type A String equal to either 'product' or 'product_group'.
|
183 |
+
* Set to product if the keys you send content_ids or contents represent products.
|
184 |
+
* Set to product_group if the keys you send in content_ids represent product groups.
|
185 |
+
* @return $this
|
186 |
+
*/
|
187 |
+
public function setContentType($content_type)
|
188 |
+
{
|
189 |
+
$this->container['content_type'] = $content_type;
|
190 |
+
return $this;
|
191 |
+
}
|
192 |
+
/**
|
193 |
+
* Sets order_id
|
194 |
+
* @param string $order_id The order ID for this transaction as a String.
|
195 |
+
* @return $this
|
196 |
+
*/
|
197 |
+
public function setOrderId($order_id)
|
198 |
+
{
|
199 |
+
$this->container['order_id'] = $order_id;
|
200 |
+
return $this;
|
201 |
+
}
|
202 |
+
/**
|
203 |
+
* Sets predicted_ltv
|
204 |
+
* @param float $predicted_ltv The predicted lifetime value of a conversion event.
|
205 |
+
* @return $this
|
206 |
+
*/
|
207 |
+
public function setPredictedLtv($predicted_ltv)
|
208 |
+
{
|
209 |
+
$this->container['predicted_ltv'] = $predicted_ltv;
|
210 |
+
return $this;
|
211 |
+
}
|
212 |
+
/**
|
213 |
+
* Sets num_items
|
214 |
+
* @param string $num_items Use only with InitiateCheckout events.
|
215 |
+
* The number of items that a user tries to buy during checkout.
|
216 |
+
* @return $this
|
217 |
+
*/
|
218 |
+
public function setNumItems($num_items)
|
219 |
+
{
|
220 |
+
$this->container['num_items'] = $num_items;
|
221 |
+
return $this;
|
222 |
+
}
|
223 |
+
/**
|
224 |
+
* Sets status
|
225 |
+
* @param string $status Use only with CompleteRegistration events.
|
226 |
+
* The status of the registration event.
|
227 |
+
* @return $this
|
228 |
+
*/
|
229 |
+
public function setStatus($status)
|
230 |
+
{
|
231 |
+
$this->container['status'] = $status;
|
232 |
+
return $this;
|
233 |
+
}
|
234 |
+
/**
|
235 |
+
* Sets a search query made by a user. Use only with Search events.
|
236 |
+
* @param string $search_string Use only with Search events.
|
237 |
+
* A search query made by a user.
|
238 |
+
* @return $this
|
239 |
+
*/
|
240 |
+
public function setSearchString($search_string)
|
241 |
+
{
|
242 |
+
$this->container['search_string'] = $search_string;
|
243 |
+
return $this;
|
244 |
+
}
|
245 |
+
/**
|
246 |
+
* Sets Type of delivery for a purchase event.
|
247 |
+
* @param string $delivery_category Type of delivery for a purchase event.
|
248 |
+
* @return $this
|
249 |
+
*/
|
250 |
+
public function setDeliveryCategory($delivery_category)
|
251 |
+
{
|
252 |
+
$this->container['delivery_category'] = $delivery_category;
|
253 |
+
return $this;
|
254 |
+
}
|
255 |
+
/**
|
256 |
+
* Sets the item_number.
|
257 |
+
* @param string $item_number The item number.
|
258 |
+
* @return $this
|
259 |
+
*/
|
260 |
+
public function setItemNumber($item_number)
|
261 |
+
{
|
262 |
+
$this->container['item_number'] = $item_number;
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
/**
|
266 |
+
* Sets custom_properties that are not defined as the standard properties list in custom data.
|
267 |
+
* @param array custom_properties dictionary to include custom properties that are not defined in custom data.
|
268 |
+
* @return $this
|
269 |
+
*/
|
270 |
+
public function setCustomProperties($custom_properties)
|
271 |
+
{
|
272 |
+
$this->container['custom_properties'] = $custom_properties;
|
273 |
+
return $this;
|
274 |
+
}
|
275 |
+
/**
|
276 |
+
* Returns true if offset exists. False otherwise.
|
277 |
+
* @param integer $offset Offset
|
278 |
+
* @return boolean
|
279 |
+
*/
|
280 |
+
public function offsetExists($offset)
|
281 |
+
{
|
282 |
+
return isset($this->container[$offset]);
|
283 |
+
}
|
284 |
+
/**
|
285 |
+
* Gets offset.
|
286 |
+
* @param integer $offset Offset
|
287 |
+
* @return mixed
|
288 |
+
*/
|
289 |
+
public function offsetGet($offset)
|
290 |
+
{
|
291 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
292 |
+
}
|
293 |
+
/**
|
294 |
+
* Sets value based on offset.
|
295 |
+
* @param integer $offset Offset
|
296 |
+
* @param mixed $value Value to be set
|
297 |
+
* @return void
|
298 |
+
*/
|
299 |
+
public function offsetSet($offset, $value)
|
300 |
+
{
|
301 |
+
if (\is_null($offset)) {
|
302 |
+
$this->container[] = $value;
|
303 |
+
} else {
|
304 |
+
$this->container[$offset] = $value;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
/**
|
308 |
+
* Unsets offset.
|
309 |
+
* @param integer $offset Offset
|
310 |
+
* @return void
|
311 |
+
*/
|
312 |
+
public function offsetUnset($offset)
|
313 |
+
{
|
314 |
+
unset($this->container[$offset]);
|
315 |
+
}
|
316 |
+
/**
|
317 |
+
* Add a custom property to the custom_properties bag
|
318 |
+
* @param $key Custom property name
|
319 |
+
* @param $value Custom property value
|
320 |
+
* @return void
|
321 |
+
*/
|
322 |
+
public function addCustomProperty($key, $value)
|
323 |
+
{
|
324 |
+
$this->container['custom_properties'][$key] = $value;
|
325 |
+
}
|
326 |
+
/**
|
327 |
+
* Gets the value of a custom property from the custom_properties bag
|
328 |
+
* @param $key Custom property name
|
329 |
+
* @return string
|
330 |
+
*/
|
331 |
+
public function getCustomProperty($key)
|
332 |
+
{
|
333 |
+
if (\array_key_exists($key, $this->container['custom_properties'])) {
|
334 |
+
return $this->container['custom_properties'][$key];
|
335 |
+
} else {
|
336 |
+
throw new \Exception("Key not found in custom properties:'" . $key . "'");
|
337 |
+
}
|
338 |
+
}
|
339 |
+
public function normalize()
|
340 |
+
{
|
341 |
+
$normalized_payload = array();
|
342 |
+
$normalized_payload['value'] = $this->getValue();
|
343 |
+
$normalized_payload['currency'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('currency', $this->getCurrency());
|
344 |
+
$normalized_payload['content_name'] = $this->getContentName();
|
345 |
+
$normalized_payload['content_category'] = $this->getContentCategory();
|
346 |
+
$normalized_payload['content_ids'] = $this->getContentIds();
|
347 |
+
$normalized_payload['content_type'] = $this->getContentType();
|
348 |
+
$normalized_payload['order_id'] = $this->getOrderId();
|
349 |
+
$normalized_payload['predicted_ltv'] = $this->getPredictedLtv();
|
350 |
+
$normalized_payload['num_items'] = $this->getNumItems();
|
351 |
+
$normalized_payload['status'] = $this->getStatus();
|
352 |
+
$normalized_payload['search_string'] = $this->getSearchString();
|
353 |
+
$normalized_payload['item_number'] = $this->getItemNumber();
|
354 |
+
$normalized_payload['delivery_category'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('delivery_category', $this->getDeliveryCategory());
|
355 |
+
if (isset($this->container['contents'])) {
|
356 |
+
$contents = [];
|
357 |
+
foreach ($this->getContents() as $content) {
|
358 |
+
\array_push($contents, $content->normalize());
|
359 |
+
}
|
360 |
+
$normalized_payload['contents'] = $contents;
|
361 |
+
}
|
362 |
+
if (isset($this->container['custom_properties'])) {
|
363 |
+
foreach ($this->getCustomProperties() as $key => $val) {
|
364 |
+
if (\array_key_exists($key, $normalized_payload)) {
|
365 |
+
throw new \Exception('Duplicate key defined as part of the custom_properties. key: "' . $key . '". Please make sure the keys defined in the custom_properties are not already available in standard custom_data property list.');
|
366 |
+
}
|
367 |
+
$normalized_payload[$key] = $val;
|
368 |
+
}
|
369 |
+
}
|
370 |
+
$normalized_payload = \array_filter($normalized_payload, function ($val) {
|
371 |
+
if (\is_array($val)) {
|
372 |
+
return \true;
|
373 |
+
} else {
|
374 |
+
return \strlen($val);
|
375 |
+
}
|
376 |
+
});
|
377 |
+
return $normalized_payload;
|
378 |
+
}
|
379 |
+
/**
|
380 |
+
* Gets a numeric value associated with this event.
|
381 |
+
* This could be a monetary value or a value in some other metric.
|
382 |
+
* @return float
|
383 |
+
*/
|
384 |
+
public function getValue()
|
385 |
+
{
|
386 |
+
return $this->container['value'];
|
387 |
+
}
|
388 |
+
/**
|
389 |
+
* Gets currency for the value specified, if applicable.
|
390 |
+
* @return string
|
391 |
+
*/
|
392 |
+
public function getCurrency()
|
393 |
+
{
|
394 |
+
return $this->container['currency'];
|
395 |
+
}
|
396 |
+
/**
|
397 |
+
* Gets content name of the page or product associated with the event. Example: 'lettuce'.
|
398 |
+
* @return string
|
399 |
+
*/
|
400 |
+
public function getContentName()
|
401 |
+
{
|
402 |
+
return $this->container['content_name'];
|
403 |
+
}
|
404 |
+
/**
|
405 |
+
* Gets the category of the content associated with the event. Example: 'grocery'
|
406 |
+
* @return string
|
407 |
+
*/
|
408 |
+
public function getContentCategory()
|
409 |
+
{
|
410 |
+
return $this->container['content_category'];
|
411 |
+
}
|
412 |
+
/**
|
413 |
+
* Gets the content IDs associated with the event,
|
414 |
+
* such as product SKUs for items in an AddToCart event: ['ABC123', 'XYZ789'].
|
415 |
+
* @return string[]
|
416 |
+
*/
|
417 |
+
public function getContentIds()
|
418 |
+
{
|
419 |
+
return $this->container['content_ids'];
|
420 |
+
}
|
421 |
+
/**
|
422 |
+
* Gets a list of Content objects that contain the product IDs associated with
|
423 |
+
* the event plus information about the products.
|
424 |
+
* @return Content[]
|
425 |
+
*/
|
426 |
+
public function getContents()
|
427 |
+
{
|
428 |
+
return $this->container['contents'];
|
429 |
+
}
|
430 |
+
/**
|
431 |
+
* Gets content type 'product' or 'product_group'
|
432 |
+
* @return string
|
433 |
+
*/
|
434 |
+
public function getContentType()
|
435 |
+
{
|
436 |
+
return $this->container['content_type'];
|
437 |
+
}
|
438 |
+
/**
|
439 |
+
* Gets the order ID for this transaction as a String.
|
440 |
+
* @return string
|
441 |
+
*/
|
442 |
+
public function getOrderId()
|
443 |
+
{
|
444 |
+
return $this->container['order_id'];
|
445 |
+
}
|
446 |
+
/**
|
447 |
+
* Gets the predicted lifetime value of a conversion event.
|
448 |
+
* @return float
|
449 |
+
*/
|
450 |
+
public function getPredictedLtv()
|
451 |
+
{
|
452 |
+
return $this->container['predicted_ltv'];
|
453 |
+
}
|
454 |
+
/**
|
455 |
+
* Gets the number of items that a user tries to buy during checkout
|
456 |
+
* @return string
|
457 |
+
*/
|
458 |
+
public function getNumItems()
|
459 |
+
{
|
460 |
+
return $this->container['num_items'];
|
461 |
+
}
|
462 |
+
/**
|
463 |
+
* Gets the status of the registration event
|
464 |
+
* @return string
|
465 |
+
*/
|
466 |
+
public function getStatus()
|
467 |
+
{
|
468 |
+
return $this->container['status'];
|
469 |
+
}
|
470 |
+
/**
|
471 |
+
* Gets a search query made by a user.
|
472 |
+
* @return string
|
473 |
+
*/
|
474 |
+
public function getSearchString()
|
475 |
+
{
|
476 |
+
return $this->container['search_string'];
|
477 |
+
}
|
478 |
+
/**
|
479 |
+
* Gets a delivery_category for a purchase order.
|
480 |
+
* @return string
|
481 |
+
*/
|
482 |
+
public function getDeliveryCategory()
|
483 |
+
{
|
484 |
+
return $this->container['delivery_category'];
|
485 |
+
}
|
486 |
+
/**
|
487 |
+
* Gets the item number.
|
488 |
+
* @return string
|
489 |
+
*/
|
490 |
+
public function getItemNumber()
|
491 |
+
{
|
492 |
+
return $this->container['item_number'];
|
493 |
+
}
|
494 |
+
/**
|
495 |
+
* Gets Custom Properties dictionary to add properties that are not defined as part of the custom data.
|
496 |
+
* @return array
|
497 |
+
*/
|
498 |
+
public function getCustomProperties()
|
499 |
+
{
|
500 |
+
return $this->container['custom_properties'];
|
501 |
+
}
|
502 |
+
/**
|
503 |
+
* Gets the string presentation of the object
|
504 |
+
* @return string
|
505 |
+
*/
|
506 |
+
public function __toString()
|
507 |
+
{
|
508 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
509 |
+
// use JSON pretty print
|
510 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
511 |
+
}
|
512 |
+
return \json_encode($this);
|
513 |
+
}
|
514 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/DeliveryCategory.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* Class DeliveryCategory
|
31 |
*
|
@@ -33,20 +32,18 @@ use FacebookAds\Enum\AbstractEnum;
|
|
33 |
*
|
34 |
* @package FacebookAds\Object\ServerSide
|
35 |
*/
|
36 |
-
class DeliveryCategory extends AbstractEnum
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
*/
|
51 |
-
const HOME_DELIVERY = 'home_delivery';
|
52 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* Class DeliveryCategory
|
30 |
*
|
32 |
*
|
33 |
* @package FacebookAds\Object\ServerSide
|
34 |
*/
|
35 |
+
class DeliveryCategory extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Customer needs to enter the store to get the purchased product.
|
39 |
+
*/
|
40 |
+
const IN_STORE = 'in_store';
|
41 |
+
/**
|
42 |
+
* Customer picks up their order by driving to a store and waiting inside their vehicle.
|
43 |
+
*/
|
44 |
+
const CURBSIDE = 'curbside';
|
45 |
+
/**
|
46 |
+
* Purchase is delivered to the customer's home.
|
47 |
+
*/
|
48 |
+
const HOME_DELIVERY = 'home_delivery';
|
|
|
|
|
49 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Event.php
ADDED
@@ -0,0 +1,426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
/**
|
29 |
+
* Server-Side Event
|
30 |
+
*
|
31 |
+
* @category Class
|
32 |
+
* @package FacebookAds\Object\ServerSide
|
33 |
+
*/
|
34 |
+
class Event implements \ArrayAccess
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Array of property to type mappings. Used for (de)serialization
|
38 |
+
* @var string[]
|
39 |
+
*/
|
40 |
+
protected static $param_types = array('event_name' => 'string', 'event_time' => 'int', 'event_source_url' => 'string', 'opt_out' => 'bool', 'event_id' => 'string', 'user_data' => 'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\UserData', 'custom_data' => 'PixelCaffeine\\Dependencies\\FacebookAds\\Object\\ServerSide\\CustomData', 'data_processing_options' => 'string[]', 'data_processing_options_country' => 'int', 'data_processing_options_state' => 'int', 'action_source' => 'string');
|
41 |
+
/**
|
42 |
+
* Array of attributes where the key is the local name, and the value is the original name
|
43 |
+
* @var string[]
|
44 |
+
*/
|
45 |
+
protected static $attributeMap = array('event_name' => 'event_name', 'event_time' => 'event_time', 'event_source_url' => 'event_source_url', 'opt_out' => 'opt_out', 'event_id' => 'event_id', 'user_data' => 'user_data', 'custom_data' => 'custom_data', 'data_processing_options' => 'data_processing_options', 'data_processing_options_country' => 'data_processing_options_country', 'data_processing_options_state' => 'data_processing_options_state', 'action_source' => 'action_source');
|
46 |
+
/**
|
47 |
+
* Array of attributes to setter functions (for deserialization of responses)
|
48 |
+
* @var string[]
|
49 |
+
*/
|
50 |
+
protected static $setters = array('event_name' => 'setEventName', 'event_time' => 'setEventTime', 'event_source_url' => 'setEventSourceUrl', 'opt_out' => 'setOptOut', 'event_id' => 'setEventId', 'user_data' => 'setUserData', 'custom_data' => 'setCustomData', 'data_processing_options' => 'setDataProcessingOptions', 'data_processing_options_country' => 'setDataProcessingOptionsCountry', 'data_processing_options_state' => 'setDataProcessingOptionsState', 'action_source' => 'setActionSource');
|
51 |
+
/**
|
52 |
+
* Array of attributes to getter functions (for serialization of requests)
|
53 |
+
* @var string[]
|
54 |
+
*/
|
55 |
+
protected static $getters = array('event_name' => 'getEventName', 'event_time' => 'getEventTime', 'event_source_url' => 'getEventSourceUrl', 'opt_out' => 'getOptOut', 'event_id' => 'getEventId', 'user_data' => 'getUserData', 'custom_data' => 'getCustomData', 'data_processing_options' => 'getDataProcessingOptions', 'data_processing_options_country' => 'getDataProcessingOptionsCountry', 'data_processing_options_state' => 'getDataProcessingOptionsState', 'action_source' => 'getActionSource');
|
56 |
+
/**
|
57 |
+
* Associative array for storing property values
|
58 |
+
* @var mixed[]
|
59 |
+
*/
|
60 |
+
protected $container = array();
|
61 |
+
/**
|
62 |
+
* Constructor
|
63 |
+
* @param mixed[] $data Associated array of property value initalizing the model
|
64 |
+
*/
|
65 |
+
public function __construct(array $data = null)
|
66 |
+
{
|
67 |
+
$this->container['event_name'] = isset($data['event_name']) ? $data['event_name'] : null;
|
68 |
+
$this->container['event_time'] = isset($data['event_time']) ? $data['event_time'] : null;
|
69 |
+
$this->container['event_source_url'] = isset($data['event_source_url']) ? $data['event_source_url'] : null;
|
70 |
+
$this->container['opt_out'] = isset($data['opt_out']) ? $data['opt_out'] : null;
|
71 |
+
$this->container['event_id'] = isset($data['event_id']) ? $data['event_id'] : null;
|
72 |
+
$this->container['user_data'] = isset($data['user_data']) ? $data['user_data'] : null;
|
73 |
+
$this->container['custom_data'] = isset($data['custom_data']) ? $data['custom_data'] : null;
|
74 |
+
$this->container['data_processing_options'] = isset($data['data_processing_options']) ? $data['data_processing_options'] : null;
|
75 |
+
$this->container['data_processing_options_country'] = isset($data['data_processing_options_country']) ? $data['data_processing_options_country'] : null;
|
76 |
+
$this->container['data_processing_options_state'] = isset($data['data_processing_options_state']) ? $data['data_processing_options_state'] : null;
|
77 |
+
$this->container['action_source'] = isset($data['action_source']) ? $data['action_source'] : null;
|
78 |
+
}
|
79 |
+
public static function paramTypes()
|
80 |
+
{
|
81 |
+
return self::$param_types;
|
82 |
+
}
|
83 |
+
public static function attributeMap()
|
84 |
+
{
|
85 |
+
return self::$attributeMap;
|
86 |
+
}
|
87 |
+
public static function setters()
|
88 |
+
{
|
89 |
+
return self::$setters;
|
90 |
+
}
|
91 |
+
public static function getters()
|
92 |
+
{
|
93 |
+
return self::$getters;
|
94 |
+
}
|
95 |
+
/**
|
96 |
+
* show all the invalid properties with reasons.
|
97 |
+
*
|
98 |
+
* @return array invalid properties with reasons
|
99 |
+
*/
|
100 |
+
public function listInvalidProperties()
|
101 |
+
{
|
102 |
+
$invalid_properties = array();
|
103 |
+
if ($this->container['event_name'] === null) {
|
104 |
+
$invalid_properties[] = "'event_name' can't be null";
|
105 |
+
}
|
106 |
+
if ($this->container['event_time'] === null) {
|
107 |
+
$invalid_properties[] = "'event_time' can't be null";
|
108 |
+
}
|
109 |
+
if ($this->container['user_data'] === null) {
|
110 |
+
$invalid_properties[] = "'user_data' can't be null";
|
111 |
+
}
|
112 |
+
return $invalid_properties;
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* validate all the properties in the model
|
116 |
+
* return true if all passed
|
117 |
+
*
|
118 |
+
* @return bool True if all properteis are valid
|
119 |
+
*/
|
120 |
+
public function valid()
|
121 |
+
{
|
122 |
+
if ($this->container['event_name'] === null) {
|
123 |
+
return \false;
|
124 |
+
}
|
125 |
+
if ($this->container['event_time'] === null) {
|
126 |
+
return \false;
|
127 |
+
}
|
128 |
+
if ($this->container['user_data'] === null) {
|
129 |
+
return \false;
|
130 |
+
}
|
131 |
+
return \true;
|
132 |
+
}
|
133 |
+
/**
|
134 |
+
* Sets a Facebook pixel Standard Event or Custom Event name
|
135 |
+
* @param string $event_name A Facebook pixel Standard Event or Custom Event name.
|
136 |
+
* @return $this
|
137 |
+
*/
|
138 |
+
public function setEventName($event_name)
|
139 |
+
{
|
140 |
+
$this->container['event_name'] = $event_name;
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* Sets a Unix timestamp in seconds indicating when the actual event occurred
|
145 |
+
* @param int $event_time A Unix timestamp in seconds indicating when the actual event occurred.
|
146 |
+
* @return $this
|
147 |
+
*/
|
148 |
+
public function setEventTime($event_time)
|
149 |
+
{
|
150 |
+
$this->container['event_time'] = $event_time;
|
151 |
+
return $this;
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* Sets the browser URL where the event happened
|
155 |
+
* @param string $event_source_url The browser URL where the event happened.
|
156 |
+
* @return $this
|
157 |
+
*/
|
158 |
+
public function setEventSourceUrl($event_source_url)
|
159 |
+
{
|
160 |
+
$this->container['event_source_url'] = $event_source_url;
|
161 |
+
return $this;
|
162 |
+
}
|
163 |
+
/**
|
164 |
+
* Sets a flag that indicates Facebook should or should not use this event for ads delivery optimization
|
165 |
+
* @param bool $opt_out A flag that indicates Facebook should or should not
|
166 |
+
* use this event for ads delivery optimization.
|
167 |
+
* If set to true, Facebook only use the event for attribution.
|
168 |
+
* @return $this
|
169 |
+
*/
|
170 |
+
public function setOptOut($opt_out)
|
171 |
+
{
|
172 |
+
$this->container['opt_out'] = $opt_out;
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* Sets an ID used by Facebook to deduplicate the same event sent from both server and browser.
|
177 |
+
* @param string $event_id This ID can be any unique string chosen by the advertiser.
|
178 |
+
* event_id is used to deduplicate events sent by both Facebook Pixel and Server-Side API.
|
179 |
+
* event_name is also used in the deduplication process.
|
180 |
+
* For deduplication, the eventID from Facebook pixel must match the
|
181 |
+
* event_id in the corresponding Server-Side API event.
|
182 |
+
* @return $this
|
183 |
+
*/
|
184 |
+
public function setEventId($event_id)
|
185 |
+
{
|
186 |
+
$this->container['event_id'] = $event_id;
|
187 |
+
return $this;
|
188 |
+
}
|
189 |
+
/**
|
190 |
+
* Sets UserData object that contains user data.
|
191 |
+
* @param FacebookAds\Object\ServerSide\UserData $user_data
|
192 |
+
* @return $this
|
193 |
+
*/
|
194 |
+
public function setUserData($user_data)
|
195 |
+
{
|
196 |
+
$this->container['user_data'] = $user_data;
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
/**
|
200 |
+
* Sets CustomData object that includes additional business data about the event.
|
201 |
+
* @param FacebookAds\Object\ServerSide\CustomData $custom_data
|
202 |
+
* @return $this
|
203 |
+
*/
|
204 |
+
public function setCustomData($custom_data)
|
205 |
+
{
|
206 |
+
$this->container['custom_data'] = $custom_data;
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
/**
|
210 |
+
* Sets the processing options you would like to enable for a specific event.
|
211 |
+
* For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options
|
212 |
+
* @param string[], e.g. [] or ['LDU']
|
213 |
+
* @return $this
|
214 |
+
*/
|
215 |
+
public function setDataProcessingOptions($data_processing_options)
|
216 |
+
{
|
217 |
+
$this->container['data_processing_options'] = $data_processing_options;
|
218 |
+
return $this;
|
219 |
+
}
|
220 |
+
/**
|
221 |
+
* Sets a country that you want to associate to this data processing option. If you set a country, you must also set a state.
|
222 |
+
* For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options
|
223 |
+
* @param int
|
224 |
+
* @return $this
|
225 |
+
*/
|
226 |
+
public function setDataProcessingOptionsCountry($data_processing_options_country)
|
227 |
+
{
|
228 |
+
$this->container['data_processing_options_country'] = $data_processing_options_country;
|
229 |
+
return $this;
|
230 |
+
}
|
231 |
+
/**
|
232 |
+
* Sets a state that you want to associate with this data processing option.
|
233 |
+
* For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options
|
234 |
+
* @param int
|
235 |
+
* @return $this
|
236 |
+
*
|
237 |
+
*/
|
238 |
+
public function setDataProcessingOptionsState($data_processing_options_state)
|
239 |
+
{
|
240 |
+
$this->container['data_processing_options_state'] = $data_processing_options_state;
|
241 |
+
return $this;
|
242 |
+
}
|
243 |
+
/**
|
244 |
+
* Gets action_source, this is where the Conversion occurred.
|
245 |
+
* @return string
|
246 |
+
*/
|
247 |
+
public function getActionSource()
|
248 |
+
{
|
249 |
+
return $this->container['action_source'];
|
250 |
+
}
|
251 |
+
/**
|
252 |
+
* Sets action_source, this is where the Conversion occurred.
|
253 |
+
* @return $this
|
254 |
+
*/
|
255 |
+
public function setActionSource($action_source)
|
256 |
+
{
|
257 |
+
$this->container['action_source'] = $action_source;
|
258 |
+
return $this;
|
259 |
+
}
|
260 |
+
/**
|
261 |
+
* Returns true if offset exists. False otherwise.
|
262 |
+
* @param integer $offset Offset
|
263 |
+
* @return boolean
|
264 |
+
*/
|
265 |
+
public function offsetExists($offset)
|
266 |
+
{
|
267 |
+
return isset($this->container[$offset]);
|
268 |
+
}
|
269 |
+
/**
|
270 |
+
* Gets offset.
|
271 |
+
* @param integer $offset Offset
|
272 |
+
* @return mixed
|
273 |
+
*/
|
274 |
+
public function offsetGet($offset)
|
275 |
+
{
|
276 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
277 |
+
}
|
278 |
+
/**
|
279 |
+
* Sets value based on offset.
|
280 |
+
* @param integer $offset Offset
|
281 |
+
* @param mixed $value Value to be set
|
282 |
+
* @return void
|
283 |
+
*/
|
284 |
+
public function offsetSet($offset, $value)
|
285 |
+
{
|
286 |
+
if (\is_null($offset)) {
|
287 |
+
$this->container[] = $value;
|
288 |
+
} else {
|
289 |
+
$this->container[$offset] = $value;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
/**
|
293 |
+
* Unsets offset.
|
294 |
+
* @param integer $offset Offset
|
295 |
+
* @return void
|
296 |
+
*/
|
297 |
+
public function offsetUnset($offset)
|
298 |
+
{
|
299 |
+
unset($this->container[$offset]);
|
300 |
+
}
|
301 |
+
/**
|
302 |
+
* Normalize
|
303 |
+
* @return array
|
304 |
+
*/
|
305 |
+
public function normalize()
|
306 |
+
{
|
307 |
+
$normalized_payload = array();
|
308 |
+
$normalized_payload['event_name'] = $this->getEventName();
|
309 |
+
$normalized_payload['event_time'] = $this->getEventTime();
|
310 |
+
$normalized_payload['event_source_url'] = $this->getEventSourceUrl();
|
311 |
+
$normalized_payload['opt_out'] = $this->getOptOut();
|
312 |
+
$normalized_payload['event_id'] = $this->getEventId();
|
313 |
+
$normalized_payload['user_data'] = isset($this->container['user_data']) ? $this->getUserData()->normalize() : null;
|
314 |
+
$normalized_payload['custom_data'] = isset($this->container['custom_data']) ? $this->getCustomData()->normalize() : null;
|
315 |
+
$normalized_payload['data_processing_options'] = $this->getDataProcessingOptions();
|
316 |
+
$normalized_payload['data_processing_options_country'] = $this->getDataProcessingOptionsCountry();
|
317 |
+
$normalized_payload['data_processing_options_state'] = $this->getDataProcessingOptionsState();
|
318 |
+
$normalized_payload['action_source'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('action_source', $this->container['action_source']);
|
319 |
+
$normalized_payload = \array_filter($normalized_payload, function ($val) {
|
320 |
+
if (\is_array($val)) {
|
321 |
+
return \true;
|
322 |
+
} else {
|
323 |
+
return \strlen($val);
|
324 |
+
}
|
325 |
+
});
|
326 |
+
// Add the opt_out value back in if it was filtered out
|
327 |
+
if ($this->getOptOut() === \false) {
|
328 |
+
$normalized_payload['opt_out'] = $this->getOptOut();
|
329 |
+
}
|
330 |
+
return $normalized_payload;
|
331 |
+
}
|
332 |
+
/**
|
333 |
+
* Gets Facebook pixel Standard Event or Custom Event name.
|
334 |
+
* @return string
|
335 |
+
*/
|
336 |
+
public function getEventName()
|
337 |
+
{
|
338 |
+
return $this->container['event_name'];
|
339 |
+
}
|
340 |
+
/**
|
341 |
+
* Gets Unix timestamp in seconds indicating when the actual event occurred.
|
342 |
+
* @return int
|
343 |
+
*/
|
344 |
+
public function getEventTime()
|
345 |
+
{
|
346 |
+
return $this->container['event_time'];
|
347 |
+
}
|
348 |
+
/**
|
349 |
+
* Gets browser URL where the event happened.
|
350 |
+
* @return string
|
351 |
+
*/
|
352 |
+
public function getEventSourceUrl()
|
353 |
+
{
|
354 |
+
return $this->container['event_source_url'];
|
355 |
+
}
|
356 |
+
/**
|
357 |
+
* Gets flag that indicates Facebook should or should not use this event for ads delivery optimization.
|
358 |
+
* If set to true, we only use the event for attribution.
|
359 |
+
* @return bool
|
360 |
+
*/
|
361 |
+
public function getOptOut()
|
362 |
+
{
|
363 |
+
return $this->container['opt_out'];
|
364 |
+
}
|
365 |
+
/**
|
366 |
+
* Gets Event ID can be any string chosen by the advertiser. It is used by Facebook to deduplicate
|
367 |
+
* the same event sent from both server and browser.
|
368 |
+
* @return string
|
369 |
+
*/
|
370 |
+
public function getEventId()
|
371 |
+
{
|
372 |
+
return $this->container['event_id'];
|
373 |
+
}
|
374 |
+
/**
|
375 |
+
* Gets UserData object that contains user data
|
376 |
+
* @return FacebookAds\Object\ServerSide\UserData
|
377 |
+
*/
|
378 |
+
public function getUserData()
|
379 |
+
{
|
380 |
+
return $this->container['user_data'];
|
381 |
+
}
|
382 |
+
/**
|
383 |
+
* Gets customData object that includes additional business data about the event.
|
384 |
+
* @return FacebookAds\Object\ServerSide\CustomData
|
385 |
+
*/
|
386 |
+
public function getCustomData()
|
387 |
+
{
|
388 |
+
return $this->container['custom_data'];
|
389 |
+
}
|
390 |
+
/**
|
391 |
+
* Gets DataProcessionOptions value of Processing options you would like to enable for a specific event.
|
392 |
+
* @return string[]
|
393 |
+
*/
|
394 |
+
public function getDataProcessingOptions()
|
395 |
+
{
|
396 |
+
return $this->container['data_processing_options'];
|
397 |
+
}
|
398 |
+
/**
|
399 |
+
* Gets DataProcessionOptionsState value that represents the state that you want to associate with this data processing option.
|
400 |
+
* @return int
|
401 |
+
*/
|
402 |
+
public function getDataProcessingOptionsState()
|
403 |
+
{
|
404 |
+
return $this->container['data_processing_options_state'];
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Gets DataProcessionOptionsCountry value that represents the country that you want to associate to this data processing option.
|
408 |
+
* @return int
|
409 |
+
*/
|
410 |
+
public function getDataProcessingOptionsCountry()
|
411 |
+
{
|
412 |
+
return $this->container['data_processing_options_country'];
|
413 |
+
}
|
414 |
+
/**
|
415 |
+
* Gets the string representation of the object
|
416 |
+
* @return string
|
417 |
+
*/
|
418 |
+
public function __toString()
|
419 |
+
{
|
420 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
421 |
+
// use JSON pretty print
|
422 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
423 |
+
}
|
424 |
+
return \json_encode($this);
|
425 |
+
}
|
426 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php
ADDED
@@ -0,0 +1,388 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiConfig;
|
30 |
+
use PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel;
|
31 |
+
/**
|
32 |
+
* Server-Side Event Request
|
33 |
+
*
|
34 |
+
* @category Class
|
35 |
+
*/
|
36 |
+
class EventRequest implements \ArrayAccess
|
37 |
+
{
|
38 |
+
/**
|
39 |
+
* Array of property to type mappings. Used for (de)serialization
|
40 |
+
* @var string[]
|
41 |
+
*/
|
42 |
+
protected static $param_types = array('events' => '\\FacebookAds\\Object\\ServerSide\\Event[]', 'test_event_code' => 'string', 'partner_agent' => 'string', 'namespace_id' => 'string', 'upload_id' => 'string', 'upload_tag' => 'string', 'upload_source' => 'string');
|
43 |
+
/**
|
44 |
+
* Array of attributes where the key is the local name, and the value is the original name
|
45 |
+
* @var string[]
|
46 |
+
*/
|
47 |
+
protected static $attributeMap = array('events' => 'events', 'test_event_code' => 'test_event_code', 'partner_agent' => 'partner_agent', 'namespace_id' => 'namespace_id', 'upload_id' => 'upload_id', 'upload_tag' => 'upload_tag', 'upload_source' => 'upload_source');
|
48 |
+
/**
|
49 |
+
* Array of attributes to setter functions (for deserialization of responses)
|
50 |
+
* @var string[]
|
51 |
+
*/
|
52 |
+
protected static $setters = array('events' => 'setEvents', 'test_event_code' => 'setTestEventCode', 'partner_agent' => 'setPartnerAgent', 'namespace_id' => 'setNamespaceId', 'upload_id' => 'setUploadId', 'upload_tag' => 'setUploadTag', 'upload_source' => 'setUploadSource');
|
53 |
+
/**
|
54 |
+
* Array of attributes to getter functions (for serialization of requests)
|
55 |
+
* @var string[]
|
56 |
+
*/
|
57 |
+
protected static $getters = array('events' => 'getEvents', 'test_event_code' => 'getTestEventCode', 'partner_agent' => 'getPartnerAgent', 'namespace_id' => 'getNamespaceId', 'upload_id' => 'getUploadId', 'upload_tag' => 'getUploadTag', 'upload_source' => 'getUploadSource');
|
58 |
+
/**
|
59 |
+
* Associative array for storing property values
|
60 |
+
* @var mixed[]
|
61 |
+
*/
|
62 |
+
protected $container = array();
|
63 |
+
protected $http_client = null;
|
64 |
+
/**
|
65 |
+
* Constructor
|
66 |
+
* @param string $pixel_id pixel id
|
67 |
+
* @param mixed[] $data Associated array of property value initializing the model
|
68 |
+
*/
|
69 |
+
public function __construct($pixel_id, array $data = null)
|
70 |
+
{
|
71 |
+
$this->container['pixel_id'] = $pixel_id;
|
72 |
+
$this->container['events'] = isset($data['events']) ? $data['events'] : null;
|
73 |
+
$this->container['test_event_code'] = isset($data['test_event_code']) ? $data['test_event_code'] : null;
|
74 |
+
$this->container['partner_agent'] = isset($data['partner_agent']) ? $data['partner_agent'] : null;
|
75 |
+
$this->container['namespace_id'] = isset($data['namespace_id']) ? $data['namespace_id'] : null;
|
76 |
+
$this->container['upload_id'] = isset($data['upload_id']) ? $data['upload_id'] : null;
|
77 |
+
$this->container['upload_tag'] = isset($data['upload_tag']) ? $data['upload_tag'] : null;
|
78 |
+
$this->container['upload_source'] = isset($data['upload_source']) ? $data['upload_source'] : null;
|
79 |
+
}
|
80 |
+
public static function paramTypes()
|
81 |
+
{
|
82 |
+
return self::$param_types;
|
83 |
+
}
|
84 |
+
public static function attributeMap()
|
85 |
+
{
|
86 |
+
return self::$attributeMap;
|
87 |
+
}
|
88 |
+
public static function setters()
|
89 |
+
{
|
90 |
+
return self::$setters;
|
91 |
+
}
|
92 |
+
public static function getters()
|
93 |
+
{
|
94 |
+
return self::$getters;
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* show all the invalid properties with reasons.
|
98 |
+
*
|
99 |
+
* @return array invalid properties with reasons
|
100 |
+
*/
|
101 |
+
public function listInvalidProperties()
|
102 |
+
{
|
103 |
+
$invalid_properties = array();
|
104 |
+
if ($this->container['events'] === null) {
|
105 |
+
$invalid_properties[] = "'events' can't be null";
|
106 |
+
}
|
107 |
+
return $invalid_properties;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* validate all the properties in the model
|
111 |
+
* return true if all passed
|
112 |
+
*
|
113 |
+
* @return bool True if all properties are valid
|
114 |
+
*/
|
115 |
+
public function valid()
|
116 |
+
{
|
117 |
+
if ($this->container['events'] === null) {
|
118 |
+
return \false;
|
119 |
+
}
|
120 |
+
return \true;
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* Sets an array of Server Event objects
|
124 |
+
* @param FacebookAds\Object\ServerSide\Event[] $events An array of Server Event objects
|
125 |
+
* @return $this
|
126 |
+
*/
|
127 |
+
public function setEvents($events)
|
128 |
+
{
|
129 |
+
$this->container['events'] = $events;
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* Gets code used to verify that your server events are received correctly by Facebook. Use this
|
134 |
+
* code to test your server events in the Test Events feature in Events Manager.
|
135 |
+
* See Test Events Tool
|
136 |
+
* (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/using-the-api#testEvents)
|
137 |
+
* for an example.
|
138 |
+
* @return string
|
139 |
+
*/
|
140 |
+
public function getTestEventCode()
|
141 |
+
{
|
142 |
+
return $this->container['test_event_code'];
|
143 |
+
}
|
144 |
+
/**
|
145 |
+
* Sets code used to verify that your server events are received correctly by Facebook. Use this
|
146 |
+
* code to test your server events in the Test Events feature in Events Manager.
|
147 |
+
* See Test Events Tool
|
148 |
+
* (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/using-the-api#testEvents)
|
149 |
+
* for an example.
|
150 |
+
* @param string $test_event_code Code used to verify that your server events are received correctly by Facebook.
|
151 |
+
* Use this code to test your server events in the Test Events feature in Events Manager. See Test Events Tool
|
152 |
+
* (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/using-the-api#testEvents)
|
153 |
+
* for an example.
|
154 |
+
* @return $this
|
155 |
+
*/
|
156 |
+
public function setTestEventCode($test_event_code)
|
157 |
+
{
|
158 |
+
$this->container['test_event_code'] = $test_event_code;
|
159 |
+
return $this;
|
160 |
+
}
|
161 |
+
/**
|
162 |
+
* Sets Partner Agent, which specifies who is sending the event.
|
163 |
+
* @param string $partner_agent The partner agent who is sending the event
|
164 |
+
* @return $this
|
165 |
+
*/
|
166 |
+
public function setPartnerAgent($partner_agent)
|
167 |
+
{
|
168 |
+
$this->container['partner_agent'] = $partner_agent;
|
169 |
+
return $this;
|
170 |
+
}
|
171 |
+
/**
|
172 |
+
* Sets a custom HTTP Client object, which overrides the default HTTP service
|
173 |
+
* used to send the event request.
|
174 |
+
* @param HttpServiceInterface $http_client An object that implements the HttpServiceInterface
|
175 |
+
* @return $this
|
176 |
+
*/
|
177 |
+
public function setHttpClient($http_client)
|
178 |
+
{
|
179 |
+
$this->http_client = $http_client;
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
/**
|
183 |
+
* Execute the request
|
184 |
+
* @return EventResponse
|
185 |
+
*/
|
186 |
+
public function execute()
|
187 |
+
{
|
188 |
+
$http_client = null;
|
189 |
+
if ($this->http_client != null) {
|
190 |
+
$http_client = $this->http_client;
|
191 |
+
} else {
|
192 |
+
$http_client = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpServiceClientConfig::getInstance()->getClient();
|
193 |
+
}
|
194 |
+
if ($http_client != null) {
|
195 |
+
return $this->httpClientExecute($http_client);
|
196 |
+
}
|
197 |
+
return $this->defaultExecute();
|
198 |
+
}
|
199 |
+
private function defaultExecute()
|
200 |
+
{
|
201 |
+
$fields = array();
|
202 |
+
$normalized_param = $this->normalize();
|
203 |
+
$ads_pixel = new \PixelCaffeine\Dependencies\FacebookAds\Object\AdsPixel($this->container['pixel_id']);
|
204 |
+
$response = $ads_pixel->createEvent($fields, $normalized_param);
|
205 |
+
$event_response = new \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\EventResponse($response->exportAllData());
|
206 |
+
return $event_response;
|
207 |
+
}
|
208 |
+
private function httpClientExecute($http_client)
|
209 |
+
{
|
210 |
+
$base_url = 'https://graph.facebook.com/v' . \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::APIVersion;
|
211 |
+
$url = $base_url . '/' . $this->container['pixel_id'] . '/events';
|
212 |
+
$headers = array('User-Agent' => 'fbbizsdk-php-v' . \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::SDKVersion, 'Accept-Encoding' => '*');
|
213 |
+
$curl_options = array(\CURLOPT_CONNECTTIMEOUT => 10, \CURLOPT_TIMEOUT => 60, \CURLOPT_RETURNTRANSFER => \true, \CURLOPT_HEADER => \true, \CURLOPT_CAINFO => \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::getCaBundlePath());
|
214 |
+
$params = $this->normalize();
|
215 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpServiceClientConfig::getInstance()->getAccessToken() == null) {
|
216 |
+
$params['access_token'] = \PixelCaffeine\Dependencies\FacebookAds\Api::instance()->getSession()->getAccessToken();
|
217 |
+
} else {
|
218 |
+
$params['access_token'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpServiceClientConfig::getInstance()->getAccessToken();
|
219 |
+
}
|
220 |
+
$appsecret = null;
|
221 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpServiceClientConfig::getInstance()->getAppsecret() == null) {
|
222 |
+
$appsecret = \PixelCaffeine\Dependencies\FacebookAds\Api::instance()->getSession()->getAppSecret();
|
223 |
+
} else {
|
224 |
+
$appsecret = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpServiceClientConfig::getInstance()->getAppsecret();
|
225 |
+
}
|
226 |
+
if ($appsecret != null) {
|
227 |
+
$params['appsecret_proof'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::getAppsecretProof($params['access_token'], $appsecret);
|
228 |
+
}
|
229 |
+
return $http_client->executeRequest($url, \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\HttpMethod::POST, $curl_options, $headers, $params);
|
230 |
+
}
|
231 |
+
/**
|
232 |
+
* Normalize
|
233 |
+
* @return array
|
234 |
+
*/
|
235 |
+
public function normalize()
|
236 |
+
{
|
237 |
+
$normalized_events = array();
|
238 |
+
$events = $this->getEvents();
|
239 |
+
if (!\is_null($events)) {
|
240 |
+
foreach ($events as $event) {
|
241 |
+
$normalized_event = $event->normalize();
|
242 |
+
\array_push($normalized_events, $normalized_event);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
$normalized_payload = array('data' => $normalized_events, 'test_event_code' => $this->container['test_event_code'], 'partner_agent' => $this->container['partner_agent'], 'namespace_id' => $this->container['namespace_id'], 'upload_id' => $this->container['upload_id'], 'upload_tag' => $this->container['upload_tag'], 'upload_source' => $this->container['upload_source']);
|
246 |
+
$normalized_payload = \array_filter($normalized_payload);
|
247 |
+
return $normalized_payload;
|
248 |
+
}
|
249 |
+
/**
|
250 |
+
* Gets an array of Server Event objects
|
251 |
+
* @return FacebookAds\Object\ServerSide\Event[]
|
252 |
+
*/
|
253 |
+
public function getEvents()
|
254 |
+
{
|
255 |
+
return $this->container['events'];
|
256 |
+
}
|
257 |
+
/**
|
258 |
+
* Gets Partner Agent, which specifies who is sending the event.
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
+
public function getPartnerAgent()
|
262 |
+
{
|
263 |
+
return $this->container['partner_agent'];
|
264 |
+
}
|
265 |
+
/**
|
266 |
+
* Gets namespace_id, a scope used to resolve extern_id or Third-party ID.
|
267 |
+
* Can be another data set or data partner ID.
|
268 |
+
* @return string
|
269 |
+
*/
|
270 |
+
public function getNamespaceId()
|
271 |
+
{
|
272 |
+
return $this->container['namespace_id'];
|
273 |
+
}
|
274 |
+
/**
|
275 |
+
* Sets namespace_id, a scope used to resolve extern_id or Third-party ID.
|
276 |
+
* Can be another data set or data partner ID.
|
277 |
+
* @return $this
|
278 |
+
*/
|
279 |
+
public function setNamespaceId($namespace_id)
|
280 |
+
{
|
281 |
+
$this->container['namespace_id'] = $namespace_id;
|
282 |
+
return $this;
|
283 |
+
}
|
284 |
+
/**
|
285 |
+
* Gets upload_id, a unique id used to denote the current set being uploaded.
|
286 |
+
* @return string
|
287 |
+
*/
|
288 |
+
public function getUploadId()
|
289 |
+
{
|
290 |
+
return $this->container['upload_id'];
|
291 |
+
}
|
292 |
+
/**
|
293 |
+
* Sets upload_id, a unique id used to denote the current set being uploaded.
|
294 |
+
* @return $this
|
295 |
+
*/
|
296 |
+
public function setUploadId($upload_id)
|
297 |
+
{
|
298 |
+
$this->container['upload_id'] = $upload_id;
|
299 |
+
return $this;
|
300 |
+
}
|
301 |
+
/**
|
302 |
+
* Gets upload_tag, a tag string added to track your Offline event uploads.
|
303 |
+
* @return string
|
304 |
+
*/
|
305 |
+
public function getUploadTag()
|
306 |
+
{
|
307 |
+
return $this->container['upload_tag'];
|
308 |
+
}
|
309 |
+
/**
|
310 |
+
* Sets upload_tag, a tag string added to track your Offline event uploads.
|
311 |
+
* @return $this
|
312 |
+
*/
|
313 |
+
public function setUploadTag($upload_tag)
|
314 |
+
{
|
315 |
+
$this->container['upload_tag'] = $upload_tag;
|
316 |
+
return $this;
|
317 |
+
}
|
318 |
+
/**
|
319 |
+
* Gets upload_source, the origin/source of data for the dataset to be uploaded.
|
320 |
+
* @return string
|
321 |
+
*/
|
322 |
+
public function getUploadSource()
|
323 |
+
{
|
324 |
+
return $this->container['upload_source'];
|
325 |
+
}
|
326 |
+
/**
|
327 |
+
* Sets upload_source, the origin/source of data for the dataset to be uploaded.
|
328 |
+
* @return $this
|
329 |
+
*/
|
330 |
+
public function setUploadSource($upload_source)
|
331 |
+
{
|
332 |
+
$this->container['upload_source'] = $upload_source;
|
333 |
+
return $this;
|
334 |
+
}
|
335 |
+
/**
|
336 |
+
* Returns true if offset exists. False otherwise.
|
337 |
+
* @param integer $offset Offset
|
338 |
+
* @return boolean
|
339 |
+
*/
|
340 |
+
public function offsetExists($offset)
|
341 |
+
{
|
342 |
+
return isset($this->container[$offset]);
|
343 |
+
}
|
344 |
+
/**
|
345 |
+
* Gets offset.
|
346 |
+
* @param integer $offset Offset
|
347 |
+
* @return mixed
|
348 |
+
*/
|
349 |
+
public function offsetGet($offset)
|
350 |
+
{
|
351 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
352 |
+
}
|
353 |
+
/**
|
354 |
+
* Sets value based on offset.
|
355 |
+
* @param integer $offset Offset
|
356 |
+
* @param mixed $value Value to be set
|
357 |
+
* @return void
|
358 |
+
*/
|
359 |
+
public function offsetSet($offset, $value)
|
360 |
+
{
|
361 |
+
if (\is_null($offset)) {
|
362 |
+
$this->container[] = $value;
|
363 |
+
} else {
|
364 |
+
$this->container[$offset] = $value;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
/**
|
368 |
+
* Unsets offset.
|
369 |
+
* @param integer $offset Offset
|
370 |
+
* @return void
|
371 |
+
*/
|
372 |
+
public function offsetUnset($offset)
|
373 |
+
{
|
374 |
+
unset($this->container[$offset]);
|
375 |
+
}
|
376 |
+
/**
|
377 |
+
* Gets the string presentation of the object
|
378 |
+
* @return string
|
379 |
+
*/
|
380 |
+
public function __toString()
|
381 |
+
{
|
382 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
383 |
+
// use JSON pretty print
|
384 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
385 |
+
}
|
386 |
+
return \json_encode($this);
|
387 |
+
}
|
388 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequestAsync.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Api;
|
28 |
+
use PixelCaffeine\Dependencies\FacebookAds\ApiConfig;
|
29 |
+
use PixelCaffeine\Dependencies\FacebookAds\Http\Client;
|
30 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Request;
|
31 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7\MultipartStream;
|
32 |
+
class EventRequestAsync extends \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\EventRequest
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Return an asynchronous request Promise
|
36 |
+
* @return \GuzzleHttp\Promise\PromiseInterface
|
37 |
+
*/
|
38 |
+
public function execute()
|
39 |
+
{
|
40 |
+
$normalized_param = $this->normalize();
|
41 |
+
$pixel_id = $this->container['pixel_id'];
|
42 |
+
return $this->eventPromise($pixel_id, $normalized_param);
|
43 |
+
}
|
44 |
+
private function eventPromise($pixel_id, array $params = array())
|
45 |
+
{
|
46 |
+
$access_token = \PixelCaffeine\Dependencies\FacebookAds\Api::instance()->getSession()->getAccessToken();
|
47 |
+
$headers = array('User-Agent' => 'fbbizsdk-php-v' . \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::APIVersion, 'Accept-Encoding' => '*');
|
48 |
+
$domain = \PixelCaffeine\Dependencies\FacebookAds\Http\Client::DEFAULT_LAST_LEVEL_DOMAIN . '.' . \PixelCaffeine\Dependencies\FacebookAds\Http\Client::DEFAULT_GRAPH_BASE_DOMAIN;
|
49 |
+
$base_url = 'https://' . $domain . '/v' . \PixelCaffeine\Dependencies\FacebookAds\ApiConfig::APIVersion;
|
50 |
+
$url = $base_url . '/' . $pixel_id . '/events';
|
51 |
+
$events_json = \PixelCaffeine\Dependencies\GuzzleHttp\json_encode($params['data']);
|
52 |
+
$multipart_contents = [['name' => 'access_token', 'contents' => $access_token, 'headers' => array('Content-Type' => 'multipart/form-data')], ['name' => 'data', 'contents' => $events_json, 'headers' => array('Content-Type' => 'multipart/form-data')]];
|
53 |
+
foreach ($params as $key => $value) {
|
54 |
+
if ($key !== 'data') {
|
55 |
+
$multipart_contents[] = ['name' => $key, 'contents' => $value, 'headers' => array('Content-Type' => 'multipart/form-data')];
|
56 |
+
}
|
57 |
+
}
|
58 |
+
$body = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\MultipartStream($multipart_contents);
|
59 |
+
$request = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Request('POST', $url, $headers, $body);
|
60 |
+
$client = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\AsyncClient::getInstance()->getClient();
|
61 |
+
return $client->sendAsync($request);
|
62 |
+
}
|
63 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventResponse.php
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
/**
|
29 |
+
* Server-Side pixel event response.
|
30 |
+
*
|
31 |
+
* @category Class
|
32 |
+
*/
|
33 |
+
class EventResponse implements \ArrayAccess
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* Array of property to type mappings. Used for (de)serialization
|
37 |
+
* @var string[]
|
38 |
+
*/
|
39 |
+
protected static $param_types = array('events_received' => 'int', 'messages' => 'string[]', 'fbtrace_id' => 'string');
|
40 |
+
/**
|
41 |
+
* Array of attributes where the key is the local name, and the value is the original name
|
42 |
+
* @var string[]
|
43 |
+
*/
|
44 |
+
protected static $attributeMap = array('events_received' => 'events_received', 'messages' => 'messages', 'fbtrace_id' => 'fbtrace_id');
|
45 |
+
/**
|
46 |
+
* Array of attributes to setter functions (for deserialization of responses)
|
47 |
+
* @var string[]
|
48 |
+
*/
|
49 |
+
protected static $setters = array('events_received' => 'setEventsReceived', 'messages' => 'setMessages', 'fbtrace_id' => 'setFbTraceId');
|
50 |
+
/**
|
51 |
+
* Array of attributes to getter functions (for serialization of requests)
|
52 |
+
* @var string[]
|
53 |
+
*/
|
54 |
+
protected static $getters = array('events_received' => 'getEventsReceived', 'messages' => 'getMessages', 'fbtrace_id' => 'getFbTraceId');
|
55 |
+
/**
|
56 |
+
* Associative array for storing property values
|
57 |
+
* @var mixed[]
|
58 |
+
*/
|
59 |
+
protected $container = array();
|
60 |
+
/**
|
61 |
+
* Constructor
|
62 |
+
* @param mixed[] $data Associated array of property value initalizing the model
|
63 |
+
*/
|
64 |
+
public function __construct(array $data = null)
|
65 |
+
{
|
66 |
+
$this->container['events_received'] = isset($data['events_received']) ? $data['events_received'] : null;
|
67 |
+
$this->container['messages'] = isset($data['messages']) ? $data['messages'] : null;
|
68 |
+
$this->container['fbtrace_id'] = isset($data['fbtrace_id']) ? $data['fbtrace_id'] : null;
|
69 |
+
}
|
70 |
+
public static function paramTypes()
|
71 |
+
{
|
72 |
+
return self::$param_types;
|
73 |
+
}
|
74 |
+
public static function attributeMap()
|
75 |
+
{
|
76 |
+
return self::$attributeMap;
|
77 |
+
}
|
78 |
+
public static function setters()
|
79 |
+
{
|
80 |
+
return self::$setters;
|
81 |
+
}
|
82 |
+
public static function getters()
|
83 |
+
{
|
84 |
+
return self::$getters;
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* show all the invalid properties with reasons.
|
88 |
+
*
|
89 |
+
* @return array invalid properties with reasons
|
90 |
+
*/
|
91 |
+
public function listInvalidProperties()
|
92 |
+
{
|
93 |
+
$invalid_properties = array();
|
94 |
+
return $invalid_properties;
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* validate all the properties in the model
|
98 |
+
* return true if all passed
|
99 |
+
*
|
100 |
+
* @return bool True if all properteis are valid
|
101 |
+
*/
|
102 |
+
public function valid()
|
103 |
+
{
|
104 |
+
return \true;
|
105 |
+
}
|
106 |
+
/**
|
107 |
+
* Gets number of events received.
|
108 |
+
* @return int
|
109 |
+
*/
|
110 |
+
public function getEventsReceived()
|
111 |
+
{
|
112 |
+
return $this->container['events_received'];
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* Sets number of events received.
|
116 |
+
* @param int $events_received number of events received.
|
117 |
+
* @return $this
|
118 |
+
*/
|
119 |
+
public function setEventsReceived($events_received)
|
120 |
+
{
|
121 |
+
$this->container['events_received'] = $events_received;
|
122 |
+
return $this;
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* Gets response messages.
|
126 |
+
* @return string[]
|
127 |
+
*/
|
128 |
+
public function getMessages()
|
129 |
+
{
|
130 |
+
return $this->container['messages'];
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* Sets response messages.
|
134 |
+
* @param string[] $messages response messages.
|
135 |
+
* @return $this
|
136 |
+
*/
|
137 |
+
public function setMessages($messages)
|
138 |
+
{
|
139 |
+
$this->container['messages'] = $messages;
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
/**
|
143 |
+
* Gets Facebook trace id
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function getFbTraceId()
|
147 |
+
{
|
148 |
+
return $this->container['fbtrace_id'];
|
149 |
+
}
|
150 |
+
/**
|
151 |
+
* Sets Facebook trace id
|
152 |
+
* @param $fbtrace_id Facebook trace id
|
153 |
+
* @return $this
|
154 |
+
*/
|
155 |
+
public function setFbTraceId($fbtrace_id)
|
156 |
+
{
|
157 |
+
$this->container['fbtrace_id'] = $fbtrace_id;
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
/**
|
161 |
+
* Returns true if offset exists. False otherwise.
|
162 |
+
* @param integer $offset Offset
|
163 |
+
* @return boolean
|
164 |
+
*/
|
165 |
+
public function offsetExists($offset)
|
166 |
+
{
|
167 |
+
return isset($this->container[$offset]);
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* Gets offset.
|
171 |
+
* @param integer $offset Offset
|
172 |
+
* @return mixed
|
173 |
+
*/
|
174 |
+
public function offsetGet($offset)
|
175 |
+
{
|
176 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
177 |
+
}
|
178 |
+
/**
|
179 |
+
* Sets value based on offset.
|
180 |
+
* @param integer $offset Offset
|
181 |
+
* @param mixed $value Value to be set
|
182 |
+
* @return void
|
183 |
+
*/
|
184 |
+
public function offsetSet($offset, $value)
|
185 |
+
{
|
186 |
+
if (\is_null($offset)) {
|
187 |
+
$this->container[] = $value;
|
188 |
+
} else {
|
189 |
+
$this->container[$offset] = $value;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
/**
|
193 |
+
* Unsets offset.
|
194 |
+
* @param integer $offset Offset
|
195 |
+
* @return void
|
196 |
+
*/
|
197 |
+
public function offsetUnset($offset)
|
198 |
+
{
|
199 |
+
unset($this->container[$offset]);
|
200 |
+
}
|
201 |
+
/**
|
202 |
+
* Gets the string presentation of the object
|
203 |
+
* @return string
|
204 |
+
*/
|
205 |
+
public function __toString()
|
206 |
+
{
|
207 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
208 |
+
// use JSON pretty print
|
209 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
210 |
+
}
|
211 |
+
return \json_encode($this);
|
212 |
+
}
|
213 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Gender.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,24 +22,19 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* Class Gender
|
31 |
* @package FacebookAds\Object\ServerSide
|
32 |
*/
|
33 |
-
class Gender extends AbstractEnum
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
);
|
43 |
-
}
|
44 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* Class Gender
|
30 |
* @package FacebookAds\Object\ServerSide
|
31 |
*/
|
32 |
+
class Gender extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
33 |
+
{
|
34 |
+
const MALE = 'm';
|
35 |
+
const FEMALE = 'f';
|
36 |
+
public function getFieldTypes()
|
37 |
+
{
|
38 |
+
return array('m' => 'string', 'f' => 'string');
|
39 |
+
}
|
40 |
+
}
|
|
|
|
|
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpMethod.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,14 +22,13 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
const GET = 'GET';
|
33 |
-
const DELETE = 'DELETE';
|
34 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
28 |
+
final class HttpMethod extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
29 |
+
{
|
30 |
+
const POST = 'POST';
|
31 |
+
const PUT = 'PUT';
|
32 |
+
const GET = 'GET';
|
33 |
+
const DELETE = 'DELETE';
|
|
|
|
|
34 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceClientConfig.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,37 +22,38 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
class HttpServiceClientConfig extends \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Singleton
|
28 |
+
{
|
29 |
+
protected $client = null;
|
30 |
+
protected $access_token = null;
|
31 |
+
protected $appsecret = null;
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
}
|
35 |
+
public function getClient()
|
36 |
+
{
|
37 |
+
return $this->client;
|
38 |
+
}
|
39 |
+
public function getAccessToken()
|
40 |
+
{
|
41 |
+
return $this->access_token;
|
42 |
+
}
|
43 |
+
public function getAppsecret()
|
44 |
+
{
|
45 |
+
return $this->appsecret;
|
46 |
+
}
|
47 |
+
public function setClient($client)
|
48 |
+
{
|
49 |
+
$this->client = $client;
|
50 |
+
}
|
51 |
+
public function setAccessToken($access_token)
|
52 |
+
{
|
53 |
+
$this->access_token = $access_token;
|
54 |
+
}
|
55 |
+
public function setAppsecret($appsecret)
|
56 |
+
{
|
57 |
+
$this->appsecret = $appsecret;
|
58 |
+
}
|
59 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/HttpServiceInterface.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,17 +22,17 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
public function executeRequest($url, $method, array $curl_options, array $headers, array $params);
|
37 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
|
27 |
+
interface HttpServiceInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @param string $url The graph API endpoint that will be requested
|
31 |
+
* @param FacebookAds\Object\ServerSide\HttpMethod $method The HTTP request method
|
32 |
+
* @param array $curl_options Contains curl options
|
33 |
+
* @param array $headers Contains HTTP request headers including User-Agent and Accept-Encoding
|
34 |
+
* @param array $params Contains request parameters including access_token, data, test_event_code, etc.
|
35 |
+
* @return FacebookAds\Object\ServerSide\EventResponse
|
36 |
+
*/
|
37 |
+
public function executeRequest($url, $method, array $curl_options, array $headers, array $params);
|
|
|
38 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php
ADDED
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use InvalidArgumentException;
|
28 |
+
/**
|
29 |
+
* Normalizer Class
|
30 |
+
*
|
31 |
+
* @category Class
|
32 |
+
* @package FacebookAds\Object\ServerSide
|
33 |
+
*/
|
34 |
+
class Normalizer
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* @param string $field to be normalized.
|
38 |
+
* @param string $data value to be normalized
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public static function normalize($field, $data)
|
42 |
+
{
|
43 |
+
if ($data == null || \strlen($data) == 0) {
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
// Check if already hashed. If yes, don't try to normalize an already hashed data.
|
47 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::isHashed($data)) {
|
48 |
+
return $data;
|
49 |
+
}
|
50 |
+
$data = \trim(\strtolower($data));
|
51 |
+
$normalized_data = $data;
|
52 |
+
switch ($field) {
|
53 |
+
case 'em':
|
54 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeEmail($data);
|
55 |
+
break;
|
56 |
+
case 'ph':
|
57 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizePhone($data);
|
58 |
+
break;
|
59 |
+
case 'zp':
|
60 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeZipCode($data);
|
61 |
+
break;
|
62 |
+
case 'ct':
|
63 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeCity($data);
|
64 |
+
break;
|
65 |
+
case 'st':
|
66 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeState($data);
|
67 |
+
break;
|
68 |
+
case 'country':
|
69 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeCountry($data);
|
70 |
+
break;
|
71 |
+
case 'currency':
|
72 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeCurrency($data);
|
73 |
+
break;
|
74 |
+
case 'f5first':
|
75 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeF5($data);
|
76 |
+
break;
|
77 |
+
case 'f5last':
|
78 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeF5($data);
|
79 |
+
break;
|
80 |
+
case 'fi':
|
81 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeFi($data);
|
82 |
+
break;
|
83 |
+
case 'dobd':
|
84 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeDobd($data);
|
85 |
+
break;
|
86 |
+
case 'dobm':
|
87 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeDobm($data);
|
88 |
+
break;
|
89 |
+
case 'doby':
|
90 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeDoby($data);
|
91 |
+
break;
|
92 |
+
case 'delivery_category':
|
93 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeDeliveryCategory($data);
|
94 |
+
break;
|
95 |
+
case 'action_source':
|
96 |
+
$normalized_data = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalizeActionSource($data);
|
97 |
+
break;
|
98 |
+
default:
|
99 |
+
}
|
100 |
+
return $normalized_data;
|
101 |
+
}
|
102 |
+
/**
|
103 |
+
* @param string $email Email address to be normalized.
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
private static function normalizeEmail($email)
|
107 |
+
{
|
108 |
+
// Validates email against RFC 822
|
109 |
+
$result = \filter_var($email, \FILTER_SANITIZE_EMAIL);
|
110 |
+
if (!\filter_var($result, \FILTER_VALIDATE_EMAIL)) {
|
111 |
+
throw new \InvalidArgumentException('Invalid email format for the passed email: ' . $email . 'Please check the passed email format.');
|
112 |
+
}
|
113 |
+
return $result;
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* @param string $city city name to be normalized.
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
private static function normalizeCity($city)
|
120 |
+
{
|
121 |
+
return \trim(\preg_replace('/[0-9.\\s\\-()]/', '', $city));
|
122 |
+
}
|
123 |
+
/**
|
124 |
+
* @param string $state state name to be normalized.
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
private static function normalizeState($state)
|
128 |
+
{
|
129 |
+
return \preg_replace('/[^a-z]/', '', $state);
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* @param string $country country code to be normalized(ISO 3166-2).
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
private static function normalizeCountry($country)
|
136 |
+
{
|
137 |
+
$result = \preg_replace('/[^a-z]/i', '', $country);
|
138 |
+
if (\strlen($result) != 2) {
|
139 |
+
throw new \InvalidArgumentException('Invalid country format passed(' . $country . '). Country Code should be a two-letter ISO Country Code');
|
140 |
+
}
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* @param string $zip postal code to be normalized.
|
145 |
+
* @return string
|
146 |
+
*/
|
147 |
+
private static function normalizeZipCode($zip)
|
148 |
+
{
|
149 |
+
// Removing the spaces from the zip code. Eg:
|
150 |
+
$zip = \preg_replace('/[ ]/', '', $zip);
|
151 |
+
// If the code has more than one part, retain the first part.
|
152 |
+
$zip = \explode('-', $zip)[0];
|
153 |
+
return $zip;
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* @param string $phone phone number to be normalized.
|
157 |
+
* @return string
|
158 |
+
*/
|
159 |
+
private static function normalizePhone($phone)
|
160 |
+
{
|
161 |
+
$result = \trim(\preg_replace('/[a-z()-]/', '', $phone));
|
162 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::isInternationalNumber($result)) {
|
163 |
+
$result = \preg_replace('/[\\-\\s+]/', '', $result);
|
164 |
+
}
|
165 |
+
return $result;
|
166 |
+
}
|
167 |
+
/**
|
168 |
+
* @param string $currency currency code to be normalized(ISO 4217).
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
private static function normalizeCurrency($currency)
|
172 |
+
{
|
173 |
+
$result = \preg_replace('/[^a-z]/i', '', $currency);
|
174 |
+
if (\strlen($result) != 3) {
|
175 |
+
throw new \InvalidArgumentException('Invalid currency format passed(' . $currency . '). Currency Code should be a three-letter ISO Currency Code');
|
176 |
+
}
|
177 |
+
return $result;
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* @param string $name A first or last name to be normalized.
|
181 |
+
* @return string
|
182 |
+
*/
|
183 |
+
private static function normalizeF5($name)
|
184 |
+
{
|
185 |
+
return \substr($name, 0, 5);
|
186 |
+
}
|
187 |
+
/**
|
188 |
+
* @param string $fi A first initial to be normalized.
|
189 |
+
* @return string
|
190 |
+
*/
|
191 |
+
private static function normalizeFi($fi)
|
192 |
+
{
|
193 |
+
return \substr($fi, 0, 1);
|
194 |
+
}
|
195 |
+
/**
|
196 |
+
* @param string $dobd A date of birth day to be normalized.
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
private static function normalizeDobd($dobd)
|
200 |
+
{
|
201 |
+
if (\strlen($dobd) == 1) {
|
202 |
+
$dobd = '0' . $dobd;
|
203 |
+
}
|
204 |
+
if (!\preg_match('/^[0-9]{2}$/', $dobd)) {
|
205 |
+
throw new \InvalidArgumentException('Invalid dobd passed(' . $dobd . '). Date of birth day should be in format "DD".');
|
206 |
+
}
|
207 |
+
$dobd_int = \intval($dobd);
|
208 |
+
$in_day_range = $dobd_int >= 1 && $dobd_int <= 31;
|
209 |
+
if (!$in_day_range) {
|
210 |
+
throw new \InvalidArgumentException('Invalid dobd passed(' . $dobd . '). Date of birth day should be in format "DD".');
|
211 |
+
}
|
212 |
+
return $dobd;
|
213 |
+
}
|
214 |
+
/**
|
215 |
+
* @param string $dobm A date of birth month to be normalized.
|
216 |
+
* @return string
|
217 |
+
*/
|
218 |
+
private static function normalizeDobm($dobm)
|
219 |
+
{
|
220 |
+
if (\strlen($dobm) == 1) {
|
221 |
+
$dobm = '0' . $dobm;
|
222 |
+
}
|
223 |
+
if (!\preg_match('/^[0-9]{2}$/', $dobm)) {
|
224 |
+
throw new \InvalidArgumentException('Invalid dobm passed(' . $dobm . '). Date of birth month should be in format "MM".');
|
225 |
+
}
|
226 |
+
$dobm_int = \intval($dobm);
|
227 |
+
$in_month_range = $dobm_int >= 1 && $dobm_int <= 12;
|
228 |
+
if (!$in_month_range) {
|
229 |
+
throw new \InvalidArgumentException('Invalid dobm passed(' . $dobm . '). Date of birth month should be in format "MM".');
|
230 |
+
}
|
231 |
+
return $dobm;
|
232 |
+
}
|
233 |
+
/**
|
234 |
+
* @param string $doby A date of birth year to be normalized.
|
235 |
+
* @return string
|
236 |
+
*/
|
237 |
+
private static function normalizeDoby($doby)
|
238 |
+
{
|
239 |
+
if (!\preg_match('/^[0-9]{4}$/', $doby)) {
|
240 |
+
throw new \InvalidArgumentException('Invalid doby passed(' . $doby . '). Date of birth year should be in format "YYYY".');
|
241 |
+
}
|
242 |
+
return $doby;
|
243 |
+
}
|
244 |
+
/**
|
245 |
+
* Normalizes the type of DeliveryCategory and throws error if invalid.
|
246 |
+
* @param string $delivery_category type of DeliveryCategory.
|
247 |
+
* @return string
|
248 |
+
*/
|
249 |
+
private static function normalizeDeliveryCategory($delivery_category)
|
250 |
+
{
|
251 |
+
$delivery_categories = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\DeliveryCategory::getInstance()->getValues();
|
252 |
+
if (!\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\DeliveryCategory::getInstance()->isValidValue($delivery_category)) {
|
253 |
+
throw new \InvalidArgumentException('Invalid delivery_category passed: ' . $delivery_category . '.Allowed values are one of ' . \implode(",", $delivery_categories));
|
254 |
+
}
|
255 |
+
return $delivery_category;
|
256 |
+
}
|
257 |
+
/**
|
258 |
+
* @param string $phone_number Phone number to be normalized.
|
259 |
+
* @return bool
|
260 |
+
*/
|
261 |
+
private static function isInternationalNumber($phone_number)
|
262 |
+
{
|
263 |
+
// Remove spaces and hyphens
|
264 |
+
$phone_number = \preg_replace('/[\\-\\s]/', '', $phone_number);
|
265 |
+
// Strip + and up to 2 leading 0s
|
266 |
+
$phone_number = \preg_replace('/^\\+?0{0,2}/', '', $phone_number);
|
267 |
+
if (\substr($phone_number, 0, 1) === '0') {
|
268 |
+
return \false;
|
269 |
+
}
|
270 |
+
// International Phone number with country calling code.
|
271 |
+
$international_number_regex = '/^\\d{1,4}\\(?\\d{2,3}\\)?\\d{4,}$/';
|
272 |
+
return \preg_match($international_number_regex, $phone_number);
|
273 |
+
}
|
274 |
+
/**
|
275 |
+
* Normalizes the action_source and throws an error if invalid.
|
276 |
+
* @param string $action_source type of DeliveryCategory.
|
277 |
+
* @return string
|
278 |
+
*/
|
279 |
+
private static function normalizeActionSource($action_source)
|
280 |
+
{
|
281 |
+
$action_sources = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\ActionSource::getInstance()->getValues();
|
282 |
+
if (!\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\ActionSource::getInstance()->isValidValue($action_source)) {
|
283 |
+
throw new \InvalidArgumentException(\sprintf('Invalid action_source passed: %s. Allowed values are one of %s', $action_source, \implode(",", $action_sources)));
|
284 |
+
}
|
285 |
+
return $action_source;
|
286 |
+
}
|
287 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Singleton.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
abstract class Singleton
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected static $instances = array();
|
33 |
+
private function __construct()
|
34 |
+
{
|
35 |
+
}
|
36 |
+
public static function getInstance()
|
37 |
+
{
|
38 |
+
$fqn = \get_called_class();
|
39 |
+
if (!\array_key_exists($fqn, static::$instances)) {
|
40 |
+
static::$instances[$fqn] = new static();
|
41 |
+
}
|
42 |
+
return static::$instances[$fqn];
|
43 |
+
}
|
44 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/UserData.php
ADDED
@@ -0,0 +1,679 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
use ArrayAccess;
|
28 |
+
/**
|
29 |
+
* UserData is a set of identifiers Facebook can use for targeted attribution.
|
30 |
+
*
|
31 |
+
* @category Class
|
32 |
+
*/
|
33 |
+
class UserData implements \ArrayAccess
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* The original name of the model.
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
protected static $swaggerModelName = 'server_side_pixel_user_data';
|
40 |
+
/**
|
41 |
+
* Array of property to type mappings. Used for (de)serialization
|
42 |
+
* @var string[]
|
43 |
+
*/
|
44 |
+
protected static $param_types = array('email' => 'string', 'phone' => 'string', 'gender' => 'string', 'date_of_birth' => 'string', 'last_name' => 'string', 'first_name' => 'string', 'ct' => 'string', 'state' => 'string', 'country_code' => 'string', 'zip_code' => 'string', 'external_id' => 'string', 'client_ip_address' => 'string', 'client_user_agent' => 'string', 'fbc' => 'string', 'fbp' => 'string', 'subscription_id' => 'string', 'fb_login_id' => 'string', 'lead_id' => 'string', 'f5first' => 'string', 'f5last' => 'string', 'fi' => 'string', 'dobd' => 'string', 'dobm' => 'string', 'doby' => 'string');
|
45 |
+
/**
|
46 |
+
* Array of attributes where the key is the local name, and the value is the original name
|
47 |
+
* @var string[]
|
48 |
+
*/
|
49 |
+
protected static $attributeMap = array('email' => 'email', 'phone' => 'phone', 'gender' => 'gender', 'date_of_birth' => 'date_of_birth', 'last_name' => 'last_name', 'first_name' => 'first_name', 'ct' => 'ct', 'state' => 'state', 'country_code' => 'country_code', 'zip_code' => 'zip_code', 'external_id' => 'external_id', 'client_ip_address' => 'client_ip_address', 'client_user_agent' => 'client_user_agent', 'fbc' => 'fbc', 'fbp' => 'fbp', 'subscription_id' => 'subscription_id', 'fb_login_id' => 'fb_login_id', 'lead_id' => 'lead_id', 'f5first' => 'f5first', 'f5last' => 'f5last', 'fi' => 'fi', 'dobd' => 'dobd', 'dobm' => 'dobm', 'doby' => 'doby');
|
50 |
+
/**
|
51 |
+
* Array of attributes to setter functions (for deserialization of responses)
|
52 |
+
* @var string[]
|
53 |
+
*/
|
54 |
+
protected static $setters = array('email' => 'setEmail', 'phone' => 'setPhone', 'gender' => 'setGender', 'date_of_birth' => 'setDateOfBirth', 'last_name' => 'setLastName', 'first_name' => 'setFirstName', 'city' => 'setCity', 'state' => 'setState', 'country_code' => 'setCountryCode', 'zip_code' => 'setZipCode', 'external_id' => 'setExternalId', 'client_ip_address' => 'setClientIpAddress', 'client_user_agent' => 'setClientUserAgent', 'fbc' => 'setFbc', 'fbp' => 'setFbp', 'subscription_id' => 'setSubscriptionId', 'fb_login_id' => 'setFbLoginId', 'lead_id' => 'setLeadId', 'f5first' => 'setF5first', 'f5last' => 'setF5last', 'fi' => 'setFi', 'dobd' => 'setDobd', 'dobm' => 'setDobm', 'doby' => 'setDoby');
|
55 |
+
/**
|
56 |
+
* Array of attributes to getter functions (for serialization of requests)
|
57 |
+
* @var string[]
|
58 |
+
*/
|
59 |
+
protected static $getters = array('email' => 'getEmail', 'phone' => 'getPhone', 'gender' => 'getGender', 'date_of_birth' => 'getDateOfBirth', 'last_name' => 'getLastName', 'first_name' => 'getFirstName', 'city' => 'getCity', 'state' => 'getState', 'country_code' => 'getCountryCode', 'zip_code' => 'getZipCode', 'external_id' => 'getExternalId', 'client_ip_address' => 'getClientIpAddress', 'client_user_agent' => 'getClientUserAgent', 'fbc' => 'getFbc', 'fbp' => 'getFbp', 'subscription_id' => 'getSubscriptionId', 'fb_login_id' => 'getFbLoginId', 'lead_id' => 'getLeadId', 'f5first' => 'getF5first', 'f5last' => 'getF5last', 'fi' => 'getFi', 'dobd' => 'getDobd', 'dobm' => 'getDobm', 'doby' => 'getDoby');
|
60 |
+
/**
|
61 |
+
* Associative array for storing property values
|
62 |
+
* @var mixed[]
|
63 |
+
*/
|
64 |
+
protected $container = array();
|
65 |
+
/**
|
66 |
+
* Constructor
|
67 |
+
* @param mixed[] $data Associated array of property value initalizing the model
|
68 |
+
*/
|
69 |
+
public function __construct(array $data = null)
|
70 |
+
{
|
71 |
+
$this->container['email'] = isset($data['email']) ? $data['email'] : null;
|
72 |
+
$this->container['phone'] = isset($data['phone']) ? $data['phone'] : null;
|
73 |
+
$this->container['gender'] = isset($data['gender']) ? $data['gender'] : null;
|
74 |
+
$this->container['date_of_birth'] = isset($data['date_of_birth']) ? $data['date_of_birth'] : null;
|
75 |
+
$this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null;
|
76 |
+
$this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null;
|
77 |
+
$this->container['city'] = isset($data['city']) ? $data['city'] : null;
|
78 |
+
$this->container['state'] = isset($data['state']) ? $data['state'] : null;
|
79 |
+
$this->container['country_code'] = isset($data['country_code']) ? $data['country_code'] : null;
|
80 |
+
$this->container['zip_code'] = isset($data['zip_code']) ? $data['zip_code'] : null;
|
81 |
+
$this->container['external_id'] = isset($data['external_id']) ? $data['external_id'] : null;
|
82 |
+
$this->container['client_ip_address'] = isset($data['client_ip_address']) ? $data['client_ip_address'] : null;
|
83 |
+
$this->container['client_user_agent'] = isset($data['client_user_agent']) ? $data['client_user_agent'] : null;
|
84 |
+
$this->container['fbc'] = isset($data['fbc']) ? $data['fbc'] : null;
|
85 |
+
$this->container['fbp'] = isset($data['fbp']) ? $data['fbp'] : null;
|
86 |
+
$this->container['subscription_id'] = isset($data['subscription_id']) ? $data['subscription_id'] : null;
|
87 |
+
$this->container['fb_login_id'] = isset($data['fb_login_id']) ? $data['fb_login_id'] : null;
|
88 |
+
$this->container['lead_id'] = isset($data['lead_id']) ? $data['lead_id'] : null;
|
89 |
+
$this->container['f5first'] = isset($data['f5first']) ? $data['f5first'] : null;
|
90 |
+
$this->container['f5last'] = isset($data['f5last']) ? $data['f5last'] : null;
|
91 |
+
$this->container['fi'] = isset($data['fi']) ? $data['fi'] : null;
|
92 |
+
$this->container['dobd'] = isset($data['dobd']) ? $data['dobd'] : null;
|
93 |
+
$this->container['dobm'] = isset($data['dobm']) ? $data['dobm'] : null;
|
94 |
+
$this->container['doby'] = isset($data['doby']) ? $data['doby'] : null;
|
95 |
+
}
|
96 |
+
public static function paramTypes()
|
97 |
+
{
|
98 |
+
return self::$param_types;
|
99 |
+
}
|
100 |
+
public static function attributeMap()
|
101 |
+
{
|
102 |
+
return self::$attributeMap;
|
103 |
+
}
|
104 |
+
public static function setters()
|
105 |
+
{
|
106 |
+
return self::$setters;
|
107 |
+
}
|
108 |
+
public static function getters()
|
109 |
+
{
|
110 |
+
return self::$gendertters;
|
111 |
+
}
|
112 |
+
/**
|
113 |
+
* show all the invalid properties with reasons.
|
114 |
+
*
|
115 |
+
* @return array invalid properties with reasons
|
116 |
+
*/
|
117 |
+
public function listInvalidProperties()
|
118 |
+
{
|
119 |
+
$invalid_properties = array();
|
120 |
+
return $invalid_properties;
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* validate all the properties in the model
|
124 |
+
* return true if all passed
|
125 |
+
*
|
126 |
+
* @return bool True if all properteis are valid
|
127 |
+
*/
|
128 |
+
public function valid()
|
129 |
+
{
|
130 |
+
return \true;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* Sets an email address, in lowercase.
|
134 |
+
*
|
135 |
+
* <p>Example: joe@eg.com
|
136 |
+
* @param string $email An email address, in lowercase.
|
137 |
+
* @return $this
|
138 |
+
*/
|
139 |
+
public function setEmail($email)
|
140 |
+
{
|
141 |
+
$this->container['email'] = $email;
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
/**
|
145 |
+
* Sets a phone number. Include only digits with countryCode code, area code, and number.
|
146 |
+
*
|
147 |
+
* <p>Example: 16505551212
|
148 |
+
* @param string $phone A phone number. Include only digits with country code, area code, and number.
|
149 |
+
* @return $this
|
150 |
+
*/
|
151 |
+
public function setPhone($phone)
|
152 |
+
{
|
153 |
+
$this->container['phone'] = $phone;
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* Sets Gender, in lowercase. Either f or m.
|
158 |
+
* @param FacebookAds\Object\ServerSide\Gender $gender Gender, in lowercase. Either f or m.
|
159 |
+
* @return $this
|
160 |
+
*/
|
161 |
+
public function setGender($gender)
|
162 |
+
{
|
163 |
+
$this->container['gender'] = $gender;
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* Sets a date of birth given as year, month, and day.
|
168 |
+
*
|
169 |
+
* <p>Example: 19971226 for December 26, 1997.
|
170 |
+
* @param string $date_of_birth A date of birth given as year, month, and day.
|
171 |
+
* @return $this
|
172 |
+
*/
|
173 |
+
public function setDateOfBirth($date_of_birth)
|
174 |
+
{
|
175 |
+
$this->container['date_of_birth'] = $date_of_birth;
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
/**
|
179 |
+
* Sets a last name in lowercase.
|
180 |
+
*
|
181 |
+
* <p>Example: smith
|
182 |
+
* @param string $last_name A last name in lowercase.
|
183 |
+
* @return $this
|
184 |
+
*/
|
185 |
+
public function setLastName($last_name)
|
186 |
+
{
|
187 |
+
$this->container['last_name'] = $last_name;
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
/**
|
191 |
+
* Sets a first name in lowercase.
|
192 |
+
*
|
193 |
+
* <p>Example: joe
|
194 |
+
* @param string $first_name A first name in lowercase.
|
195 |
+
* @return $this
|
196 |
+
*/
|
197 |
+
public function setFirstName($first_name)
|
198 |
+
{
|
199 |
+
$this->container['first_name'] = $first_name;
|
200 |
+
return $this;
|
201 |
+
}
|
202 |
+
/**
|
203 |
+
* Sets a city in lower-case without spaces or punctuation.
|
204 |
+
*
|
205 |
+
* <p>Example: menlopark
|
206 |
+
* @param string $city A city in lower-case without spaces or punctuation.
|
207 |
+
* @return $this
|
208 |
+
*/
|
209 |
+
public function setCity($city)
|
210 |
+
{
|
211 |
+
$this->container['city'] = $city;
|
212 |
+
return $this;
|
213 |
+
}
|
214 |
+
/**
|
215 |
+
* Sets a two-letter state code in lowercase.
|
216 |
+
*
|
217 |
+
* <p>Example: ca
|
218 |
+
* @param string $state A two-letter state code in lowercase.
|
219 |
+
* @return $this
|
220 |
+
*/
|
221 |
+
public function setState($state)
|
222 |
+
{
|
223 |
+
$this->container['state'] = $state;
|
224 |
+
return $this;
|
225 |
+
}
|
226 |
+
/**
|
227 |
+
* Sets a two-letter country code in lowercase.
|
228 |
+
*
|
229 |
+
* <p>Example: us
|
230 |
+
* @param string $country_code two-letter country code in lowercase.
|
231 |
+
* @return $this
|
232 |
+
*/
|
233 |
+
public function setCountryCode($country_code)
|
234 |
+
{
|
235 |
+
$this->container['country_code'] = $country_code;
|
236 |
+
return $this;
|
237 |
+
}
|
238 |
+
/**
|
239 |
+
* Sets a five-digit zip code.
|
240 |
+
*
|
241 |
+
* <p>Example: 94035
|
242 |
+
* @param string $zip_code A five-digit zip code.
|
243 |
+
* @return $this
|
244 |
+
*/
|
245 |
+
public function setZipCode($zip_code)
|
246 |
+
{
|
247 |
+
$this->container['zip_code'] = $zip_code;
|
248 |
+
return $this;
|
249 |
+
}
|
250 |
+
/**
|
251 |
+
* Sets any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external
|
252 |
+
* cookie IDs. In the Offline Conversions API, this is known as extern_id. For more information,
|
253 |
+
* see Offline Conversions, Providing External IDs. If External ID is being sent via other
|
254 |
+
* channels, then it should be sent in the same format via the server-side API.
|
255 |
+
* @param string $external_id Any unique ID from the advertiser, such as loyalty membership IDs,
|
256 |
+
* user IDs, and external cookie IDs.
|
257 |
+
* @return $this
|
258 |
+
*/
|
259 |
+
public function setExternalId($external_id)
|
260 |
+
{
|
261 |
+
$this->container['external_id'] = $external_id;
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
/**
|
265 |
+
* Sets IP address of the browser corresponding to the event.
|
266 |
+
* @param string $client_ip_address The IP address of the browser corresponding to the event.
|
267 |
+
* @return $this
|
268 |
+
*/
|
269 |
+
public function setClientIpAddress($client_ip_address)
|
270 |
+
{
|
271 |
+
$this->container['client_ip_address'] = $client_ip_address;
|
272 |
+
return $this;
|
273 |
+
}
|
274 |
+
/**
|
275 |
+
* Sets user agent for the browser corresponding to the event.
|
276 |
+
* @param string $client_user_agent The user agent for the browser corresponding to the event.
|
277 |
+
* @return $this
|
278 |
+
*/
|
279 |
+
public function setClientUserAgent($client_user_agent)
|
280 |
+
{
|
281 |
+
$this->container['client_user_agent'] = $client_user_agent;
|
282 |
+
return $this;
|
283 |
+
}
|
284 |
+
/**
|
285 |
+
* Sets Facebook click ID value stored in the _fbc browser cookie under your domain. See Managing
|
286 |
+
* fbc and fbp Parameters for how to get this value
|
287 |
+
* (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc),
|
288 |
+
* or generate this value from a fbclid query parameter.
|
289 |
+
* @param string $fbc The Facebook click ID value stored in the _fbc browser cookie under your domain.
|
290 |
+
* @return $this
|
291 |
+
*/
|
292 |
+
public function setFbc($fbc)
|
293 |
+
{
|
294 |
+
$this->container['fbc'] = $fbc;
|
295 |
+
return $this;
|
296 |
+
}
|
297 |
+
/**
|
298 |
+
* Sets Set Facebook browser ID value stored in the _fbp browser cookie under your domain. See Managing
|
299 |
+
* fbc and fbp Parameters for how to get this value
|
300 |
+
* (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc),
|
301 |
+
* or generate this value from a fbclid query parameter.
|
302 |
+
* @param string $fbp The Facebook browser ID value stored in the _fbp browser cookie under your domain.
|
303 |
+
* @return $this
|
304 |
+
*/
|
305 |
+
public function setFbp($fbp)
|
306 |
+
{
|
307 |
+
$this->container['fbp'] = $fbp;
|
308 |
+
return $this;
|
309 |
+
}
|
310 |
+
/**
|
311 |
+
* Sets subscription ID for the user in this transaction. This is similar to the order ID for an
|
312 |
+
* individual product.
|
313 |
+
* @param string $subscription_id The subscription ID for the user in this transaction.
|
314 |
+
* @return $this
|
315 |
+
*/
|
316 |
+
public function setSubscriptionId($subscription_id)
|
317 |
+
{
|
318 |
+
$this->container['subscription_id'] = $subscription_id;
|
319 |
+
return $this;
|
320 |
+
}
|
321 |
+
/**
|
322 |
+
* Sets FbLogin ID for the user in this transaction.
|
323 |
+
* ID issued by Facebook when a person first logs into an instance of an app.
|
324 |
+
* This is also known as App-Scoped ID.
|
325 |
+
* @param string $fb_login_id The Fb_Login_Id for the user in this transaction.
|
326 |
+
* @return $this
|
327 |
+
*/
|
328 |
+
public function setFbLoginId($fb_login_id)
|
329 |
+
{
|
330 |
+
$this->container['fb_login_id'] = $fb_login_id;
|
331 |
+
return $this;
|
332 |
+
}
|
333 |
+
/**
|
334 |
+
* Sets lead_id for the user in this transaction.
|
335 |
+
* A lead_id is associated with a lead generated by Facebook's Lead Ads.
|
336 |
+
* @param string $lead_id The lead_id for the user in this transaction.
|
337 |
+
* @return $this
|
338 |
+
*/
|
339 |
+
public function setLeadId($lead_id)
|
340 |
+
{
|
341 |
+
$this->container['lead_id'] = $lead_id;
|
342 |
+
return $this;
|
343 |
+
}
|
344 |
+
/**
|
345 |
+
* Sets the first 5 letters of the first name.
|
346 |
+
* @param string $f5first The first 5 letters of the first name.
|
347 |
+
* @return $this
|
348 |
+
*/
|
349 |
+
public function setF5first($f5first)
|
350 |
+
{
|
351 |
+
$this->container['f5first'] = $f5first;
|
352 |
+
return $this;
|
353 |
+
}
|
354 |
+
/**
|
355 |
+
* Sets the first 5 letters of the last name.
|
356 |
+
* @param string $f5last The first 5 letters of the last name.
|
357 |
+
* @return $this
|
358 |
+
*/
|
359 |
+
public function setF5last($f5last)
|
360 |
+
{
|
361 |
+
$this->container['f5last'] = $f5last;
|
362 |
+
return $this;
|
363 |
+
}
|
364 |
+
/**
|
365 |
+
* Sets the first initial.
|
366 |
+
* @param string $fi The first initial.
|
367 |
+
* @return $this
|
368 |
+
*/
|
369 |
+
public function setFi($fi)
|
370 |
+
{
|
371 |
+
$this->container['fi'] = $fi;
|
372 |
+
return $this;
|
373 |
+
}
|
374 |
+
/**
|
375 |
+
* Sets the date of birth day.
|
376 |
+
* @param string $dobd The date of birth day.
|
377 |
+
* @return $this
|
378 |
+
*/
|
379 |
+
public function setDobd($dobd)
|
380 |
+
{
|
381 |
+
$this->container['dobd'] = $dobd;
|
382 |
+
return $this;
|
383 |
+
}
|
384 |
+
/**
|
385 |
+
* Sets the date of birth month.
|
386 |
+
* @param string $dobm The date of birth month.
|
387 |
+
* @return $this
|
388 |
+
*/
|
389 |
+
public function setDobm($dobm)
|
390 |
+
{
|
391 |
+
$this->container['dobm'] = $dobm;
|
392 |
+
return $this;
|
393 |
+
}
|
394 |
+
/**
|
395 |
+
* Sets the date of birth year.
|
396 |
+
* @param string $doby The date of birth year.
|
397 |
+
* @return $this
|
398 |
+
*/
|
399 |
+
public function setDoby($doby)
|
400 |
+
{
|
401 |
+
$this->container['doby'] = $doby;
|
402 |
+
return $this;
|
403 |
+
}
|
404 |
+
/**
|
405 |
+
* Returns true if offset exists. False otherwise.
|
406 |
+
* @param integer $offset Offset
|
407 |
+
* @return boolean
|
408 |
+
*/
|
409 |
+
public function offsetExists($offset)
|
410 |
+
{
|
411 |
+
return isset($this->container[$offset]);
|
412 |
+
}
|
413 |
+
/**
|
414 |
+
* Gets offset.
|
415 |
+
* @param integer $offset Offset
|
416 |
+
* @return mixed
|
417 |
+
*/
|
418 |
+
public function offsetGet($offset)
|
419 |
+
{
|
420 |
+
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
421 |
+
}
|
422 |
+
/**
|
423 |
+
* Sets value based on offset.
|
424 |
+
* @param integer $offset Offset
|
425 |
+
* @param mixed $value Value to be set
|
426 |
+
* @return void
|
427 |
+
*/
|
428 |
+
public function offsetSet($offset, $value)
|
429 |
+
{
|
430 |
+
if (\is_null($offset)) {
|
431 |
+
$this->container[] = $value;
|
432 |
+
} else {
|
433 |
+
$this->container[$offset] = $value;
|
434 |
+
}
|
435 |
+
}
|
436 |
+
/**
|
437 |
+
* Unsets offset.
|
438 |
+
* @param integer $offset Offset
|
439 |
+
* @return void
|
440 |
+
*/
|
441 |
+
public function offsetUnset($offset)
|
442 |
+
{
|
443 |
+
unset($this->container[$offset]);
|
444 |
+
}
|
445 |
+
public function normalize()
|
446 |
+
{
|
447 |
+
$normalized_payload = array();
|
448 |
+
$normalized_payload['em'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('em', $this->getEmail()));
|
449 |
+
$normalized_payload['ph'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('ph', $this->getPhone()));
|
450 |
+
$normalized_payload['ge'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('ge', $this->getGender()));
|
451 |
+
$normalized_payload['db'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('db', $this->getDateOfBirth()));
|
452 |
+
$normalized_payload['ln'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('ln', $this->getLastName()));
|
453 |
+
$normalized_payload['fn'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('fn', $this->getFirstName()));
|
454 |
+
$normalized_payload['ct'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('ct', $this->getCity()));
|
455 |
+
$normalized_payload['st'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('st', $this->getState()));
|
456 |
+
$normalized_payload['zp'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('zp', $this->getZipCode()));
|
457 |
+
$normalized_payload['country'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('country', $this->getCountryCode()));
|
458 |
+
$normalized_payload['external_id'] = $this->getExternalId();
|
459 |
+
$normalized_payload['client_ip_address'] = $this->getClientIpAddress();
|
460 |
+
$normalized_payload['client_user_agent'] = $this->getClientUserAgent();
|
461 |
+
$normalized_payload['fbc'] = $this->getFbc();
|
462 |
+
$normalized_payload['fbp'] = $this->getFbp();
|
463 |
+
$normalized_payload['subscription_id'] = $this->getSubscriptionId();
|
464 |
+
$normalized_payload['fb_login_id'] = $this->getFbLoginId();
|
465 |
+
$normalized_payload['lead_id'] = $this->getLeadId();
|
466 |
+
$normalized_payload['f5first'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('f5first', $this->getF5first()));
|
467 |
+
$normalized_payload['f5last'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('f5last', $this->getF5last()));
|
468 |
+
$normalized_payload['fi'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('fi', $this->getFi()));
|
469 |
+
$normalized_payload['dobd'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('dobd', $this->getDobd()));
|
470 |
+
$normalized_payload['dobm'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('dobm', $this->getDobm()));
|
471 |
+
$normalized_payload['doby'] = \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::hash(\PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Normalizer::normalize('doby', $this->getDoby()));
|
472 |
+
$normalized_payload = \array_filter($normalized_payload);
|
473 |
+
return $normalized_payload;
|
474 |
+
}
|
475 |
+
/**
|
476 |
+
* Gets an email address, in lowercase.
|
477 |
+
* @return string
|
478 |
+
*/
|
479 |
+
public function getEmail()
|
480 |
+
{
|
481 |
+
return $this->container['email'];
|
482 |
+
}
|
483 |
+
/**
|
484 |
+
* Gets a phone number
|
485 |
+
* @return string
|
486 |
+
*/
|
487 |
+
public function getPhone()
|
488 |
+
{
|
489 |
+
return $this->container['phone'];
|
490 |
+
}
|
491 |
+
/**
|
492 |
+
* Gets gender.
|
493 |
+
* @return string
|
494 |
+
*/
|
495 |
+
public function getGender()
|
496 |
+
{
|
497 |
+
return $this->container['gender'];
|
498 |
+
}
|
499 |
+
/**
|
500 |
+
* Gets Date Of Birth.
|
501 |
+
* @return string
|
502 |
+
*/
|
503 |
+
public function getDateOfBirth()
|
504 |
+
{
|
505 |
+
return $this->container['date_of_birth'];
|
506 |
+
}
|
507 |
+
/**
|
508 |
+
* Gets Last Name.
|
509 |
+
* @return string
|
510 |
+
*/
|
511 |
+
public function getLastName()
|
512 |
+
{
|
513 |
+
return $this->container['last_name'];
|
514 |
+
}
|
515 |
+
/**
|
516 |
+
* Gets First Name.
|
517 |
+
* @return string
|
518 |
+
*/
|
519 |
+
public function getFirstName()
|
520 |
+
{
|
521 |
+
return $this->container['first_name'];
|
522 |
+
}
|
523 |
+
/**
|
524 |
+
* Gets city.
|
525 |
+
* @return string
|
526 |
+
*/
|
527 |
+
public function getCity()
|
528 |
+
{
|
529 |
+
return $this->container['city'];
|
530 |
+
}
|
531 |
+
/**
|
532 |
+
* Gets state.
|
533 |
+
* @return string
|
534 |
+
*/
|
535 |
+
public function getState()
|
536 |
+
{
|
537 |
+
return $this->container['state'];
|
538 |
+
}
|
539 |
+
/**
|
540 |
+
* Gets zip code
|
541 |
+
* @return string
|
542 |
+
*/
|
543 |
+
public function getZipCode()
|
544 |
+
{
|
545 |
+
return $this->container['zip_code'];
|
546 |
+
}
|
547 |
+
/**
|
548 |
+
* Gets country code.
|
549 |
+
* @return string
|
550 |
+
*/
|
551 |
+
public function getCountryCode()
|
552 |
+
{
|
553 |
+
return $this->container['country_code'];
|
554 |
+
}
|
555 |
+
/**
|
556 |
+
* Gets Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.
|
557 |
+
* @return string
|
558 |
+
*/
|
559 |
+
public function getExternalId()
|
560 |
+
{
|
561 |
+
return $this->container['external_id'];
|
562 |
+
}
|
563 |
+
/**
|
564 |
+
* Gets IP address of the browser corresponding to the event.
|
565 |
+
* @return string
|
566 |
+
*/
|
567 |
+
public function getClientIpAddress()
|
568 |
+
{
|
569 |
+
return $this->container['client_ip_address'];
|
570 |
+
}
|
571 |
+
/**
|
572 |
+
* Gets user agent for the browser corresponding to the event.
|
573 |
+
* @return string
|
574 |
+
*/
|
575 |
+
public function getClientUserAgent()
|
576 |
+
{
|
577 |
+
return $this->container['client_user_agent'];
|
578 |
+
}
|
579 |
+
/**
|
580 |
+
* Gets the Facebook click ID value stored in the _fbc browser cookie under your domain.
|
581 |
+
* @return string
|
582 |
+
*/
|
583 |
+
public function getFbc()
|
584 |
+
{
|
585 |
+
return $this->container['fbc'];
|
586 |
+
}
|
587 |
+
/**
|
588 |
+
* Gets the Facebook browser ID value stored in the _fbp browser cookie under your domain.
|
589 |
+
* @return string
|
590 |
+
*/
|
591 |
+
public function getFbp()
|
592 |
+
{
|
593 |
+
return $this->container['fbp'];
|
594 |
+
}
|
595 |
+
/**
|
596 |
+
* Gets the subscription ID for the user in this transaction.
|
597 |
+
* @return string
|
598 |
+
*/
|
599 |
+
public function getSubscriptionId()
|
600 |
+
{
|
601 |
+
return $this->container['subscription_id'];
|
602 |
+
}
|
603 |
+
/**
|
604 |
+
* Gets the FbLogin ID for the user in this transaction.
|
605 |
+
* @return string
|
606 |
+
*/
|
607 |
+
public function getFbLoginId()
|
608 |
+
{
|
609 |
+
return $this->container['fb_login_id'];
|
610 |
+
}
|
611 |
+
/**
|
612 |
+
* Gets the lead_id for the user in this transaction.
|
613 |
+
* @return string
|
614 |
+
*/
|
615 |
+
public function getLeadId()
|
616 |
+
{
|
617 |
+
return $this->container['lead_id'];
|
618 |
+
}
|
619 |
+
/**
|
620 |
+
* Gets the first 5 letters of the first name.
|
621 |
+
* @return string
|
622 |
+
*/
|
623 |
+
public function getF5first()
|
624 |
+
{
|
625 |
+
return $this->container['f5first'];
|
626 |
+
}
|
627 |
+
/**
|
628 |
+
* Gets the first 5 letters of the last name.
|
629 |
+
* @return string
|
630 |
+
*/
|
631 |
+
public function getF5last()
|
632 |
+
{
|
633 |
+
return $this->container['f5last'];
|
634 |
+
}
|
635 |
+
/**
|
636 |
+
* Gets the first initial.
|
637 |
+
* @return string
|
638 |
+
*/
|
639 |
+
public function getFi()
|
640 |
+
{
|
641 |
+
return $this->container['fi'];
|
642 |
+
}
|
643 |
+
/**
|
644 |
+
* Gets the date of birth day.
|
645 |
+
* @return string
|
646 |
+
*/
|
647 |
+
public function getDobd()
|
648 |
+
{
|
649 |
+
return $this->container['dobd'];
|
650 |
+
}
|
651 |
+
/**
|
652 |
+
* Gets the date of birth month.
|
653 |
+
* @return string
|
654 |
+
*/
|
655 |
+
public function getDobm()
|
656 |
+
{
|
657 |
+
return $this->container['dobm'];
|
658 |
+
}
|
659 |
+
/**
|
660 |
+
* Gets the date of birth year.
|
661 |
+
* @return string
|
662 |
+
*/
|
663 |
+
public function getDoby()
|
664 |
+
{
|
665 |
+
return $this->container['doby'];
|
666 |
+
}
|
667 |
+
/**
|
668 |
+
* Gets the string presentation of the object
|
669 |
+
* @return string
|
670 |
+
*/
|
671 |
+
public function __toString()
|
672 |
+
{
|
673 |
+
if (\defined('JSON_PRETTY_PRINT')) {
|
674 |
+
// use JSON pretty print
|
675 |
+
return \json_encode($this, \JSON_PRETTY_PRINT);
|
676 |
+
}
|
677 |
+
return \json_encode($this);
|
678 |
+
}
|
679 |
+
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Util.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Util Class
|
29 |
+
*
|
30 |
+
* @category Class
|
31 |
+
* @package FacebookAds\Object\ServerSide
|
32 |
+
*/
|
33 |
+
class Util
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* @param string $data hash input data using SHA256 algorithm.
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public static function hash($data)
|
40 |
+
{
|
41 |
+
if ($data == null || \PixelCaffeine\Dependencies\FacebookAds\Object\ServerSide\Util::isHashed($data)) {
|
42 |
+
return $data;
|
43 |
+
}
|
44 |
+
return \hash('sha256', $data, \false);
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* @param string $pii PII data to check if its hashed.
|
48 |
+
* @return bool
|
49 |
+
*/
|
50 |
+
public static function isHashed($pii)
|
51 |
+
{
|
52 |
+
// it could be sha256 or md5
|
53 |
+
return \preg_match('/^[A-Fa-f0-9]{64}$/', $pii) || \preg_match('/^[a-f0-9]{32}$/', $pii);
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* Extracts the IP Address from the PHP Request Context.
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public static function getIpAddress()
|
60 |
+
{
|
61 |
+
$ip_address = null;
|
62 |
+
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
63 |
+
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
|
64 |
+
} else {
|
65 |
+
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
66 |
+
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
67 |
+
} else {
|
68 |
+
if (!empty($_SERVER['REMOTE_ADDR'])) {
|
69 |
+
$ip_address = $_SERVER['REMOTE_ADDR'];
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return $ip_address;
|
74 |
+
}
|
75 |
+
/**
|
76 |
+
* Extracts the HTTP User Agent from the PHP Request Context.
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public static function getHttpUserAgent()
|
80 |
+
{
|
81 |
+
$user_agent = null;
|
82 |
+
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
83 |
+
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
84 |
+
}
|
85 |
+
return $user_agent;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* Extracts the URI from the PHP Request Context.
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public static function getRequestUri()
|
92 |
+
{
|
93 |
+
$url = "http://";
|
94 |
+
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
|
95 |
+
$url = "https://";
|
96 |
+
}
|
97 |
+
if (!empty($_SERVER['HTTP_HOST'])) {
|
98 |
+
$url .= $_SERVER['HTTP_HOST'];
|
99 |
+
}
|
100 |
+
if (!empty($_SERVER['REQUEST_URI'])) {
|
101 |
+
$url .= $_SERVER['REQUEST_URI'];
|
102 |
+
}
|
103 |
+
return $url;
|
104 |
+
}
|
105 |
+
/**
|
106 |
+
* Extracts the FBP cookie from the PHP Request Context.
|
107 |
+
* @return string
|
108 |
+
*/
|
109 |
+
public static function getFbp()
|
110 |
+
{
|
111 |
+
$fbp = null;
|
112 |
+
if (!empty($_COOKIE['_fbp'])) {
|
113 |
+
$fbp = $_COOKIE['_fbp'];
|
114 |
+
}
|
115 |
+
return $fbp;
|
116 |
+
}
|
117 |
+
/**
|
118 |
+
* Extracts the FBC cookie from the PHP Request Context.
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public static function getFbc()
|
122 |
+
{
|
123 |
+
$fbc = null;
|
124 |
+
if (!empty($_COOKIE['_fbc'])) {
|
125 |
+
$fbc = $_COOKIE['_fbc'];
|
126 |
+
}
|
127 |
+
return $fbc;
|
128 |
+
}
|
129 |
+
public static function getCaBundlePath()
|
130 |
+
{
|
131 |
+
return __DIR__ . \DIRECTORY_SEPARATOR . \str_repeat('..' . \DIRECTORY_SEPARATOR, 4) . 'fb_ca_chain_bundle.crt';
|
132 |
+
}
|
133 |
+
public static function getAppsecretProof($access_token, $appsecret)
|
134 |
+
{
|
135 |
+
return \hash_hmac('sha256', $access_token, $appsecret);
|
136 |
+
}
|
137 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelAutomaticMatchingFieldsValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,17 +34,17 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelAutomaticMatchingFieldsValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelAutomaticMatchingFieldsValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelAutomaticMatchingFieldsValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelAutomaticMatchingFieldsValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const COUNTRY = 'country';
|
40 |
+
const CT = 'ct';
|
41 |
+
const DB = 'db';
|
42 |
+
const EM = 'em';
|
43 |
+
const EXTERNAL_ID = 'external_id';
|
44 |
+
const FN = 'fn';
|
45 |
+
const GE = 'ge';
|
46 |
+
const LN = 'ln';
|
47 |
+
const PH = 'ph';
|
48 |
+
const ST = 'st';
|
49 |
+
const ZP = 'zp';
|
50 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelDataUseSettingValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,9 +34,9 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelDataUseSettingValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelDataUseSettingValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelDataUseSettingValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelDataUseSettingValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const ADVERTISING_AND_ANALYTICS = 'ADVERTISING_AND_ANALYTICS';
|
40 |
+
const ANALYTICS_ONLY = 'ANALYTICS_ONLY';
|
41 |
+
const VALUE_EMPTY = 'EMPTY';
|
42 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelFirstPartyCookieStatusValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,9 +34,9 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelFirstPartyCookieStatusValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelFirstPartyCookieStatusValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelFirstPartyCookieStatusValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelFirstPartyCookieStatusValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const VALUE_EMPTY = 'EMPTY';
|
40 |
+
const FIRST_PARTY_COOKIE_DISABLED = 'FIRST_PARTY_COOKIE_DISABLED';
|
41 |
+
const FIRST_PARTY_COOKIE_ENABLED = 'FIRST_PARTY_COOKIE_ENABLED';
|
42 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelSortByValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,8 +34,8 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelSortByValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelSortByValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelSortByValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelSortByValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const LAST_FIRED_TIME = 'LAST_FIRED_TIME';
|
40 |
+
const NAME = 'NAME';
|
41 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelStatsResultAggregationValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,22 +34,22 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelStatsResultAggregationValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelStatsResultAggregationValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelStatsResultAggregationValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelStatsResultAggregationValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const BROWSER_TYPE = 'browser_type';
|
40 |
+
const CUSTOM_DATA_FIELD = 'custom_data_field';
|
41 |
+
const DEVICE_OS = 'device_os';
|
42 |
+
const DEVICE_TYPE = 'device_type';
|
43 |
+
const EVENT = 'event';
|
44 |
+
const EVENT_DETECTION_METHOD = 'event_detection_method';
|
45 |
+
const EVENT_PROCESSING_RESULTS = 'event_processing_results';
|
46 |
+
const EVENT_SOURCE = 'event_source';
|
47 |
+
const EVENT_TOTAL_COUNTS = 'event_total_counts';
|
48 |
+
const EVENT_VALUE_COUNT = 'event_value_count';
|
49 |
+
const HAD_PII = 'had_pii';
|
50 |
+
const HOST = 'host';
|
51 |
+
const MATCH_KEYS = 'match_keys';
|
52 |
+
const PIXEL_FIRE = 'pixel_fire';
|
53 |
+
const URL = 'url';
|
54 |
+
const URL_BY_RULE = 'url_by_rule';
|
55 |
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/Object/Values/AdsPixelTasksValues.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,11 +22,9 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
use FacebookAds\Enum\AbstractEnum;
|
28 |
-
|
29 |
/**
|
30 |
* This class is auto-generated.
|
31 |
*
|
@@ -35,8 +34,8 @@ use FacebookAds\Enum\AbstractEnum;
|
|
35 |
*
|
36 |
* @method static AdsPixelTasksValues getInstance()
|
37 |
*/
|
38 |
-
class AdsPixelTasksValues extends AbstractEnum
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds\Object\Values;
|
26 |
|
27 |
+
use PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum;
|
|
|
|
|
|
|
28 |
/**
|
29 |
* This class is auto-generated.
|
30 |
*
|
34 |
*
|
35 |
* @method static AdsPixelTasksValues getInstance()
|
36 |
*/
|
37 |
+
class AdsPixelTasksValues extends \PixelCaffeine\Dependencies\FacebookAds\Enum\AbstractEnum
|
38 |
+
{
|
39 |
+
const ANALYZE = 'ANALYZE';
|
40 |
+
const EDIT = 'EDIT';
|
41 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/Session.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
class Session implements \PixelCaffeine\Dependencies\FacebookAds\SessionInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $appId;
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
protected $appSecret;
|
37 |
+
/**
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
protected $accessToken;
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $appSecretProof;
|
45 |
+
/**
|
46 |
+
* @param string $app_id
|
47 |
+
* @param string $app_secret
|
48 |
+
* @param string $access_token
|
49 |
+
*/
|
50 |
+
public function __construct($app_id, $app_secret, $access_token)
|
51 |
+
{
|
52 |
+
$this->appId = $app_id;
|
53 |
+
$this->appSecret = $app_secret;
|
54 |
+
$this->accessToken = $access_token;
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getAppId()
|
60 |
+
{
|
61 |
+
return $this->appId;
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getAppSecret()
|
67 |
+
{
|
68 |
+
return $this->appSecret;
|
69 |
+
}
|
70 |
+
/**
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getAccessToken()
|
74 |
+
{
|
75 |
+
return $this->accessToken;
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getAppSecretProof()
|
81 |
+
{
|
82 |
+
if ($this->getAppSecret() === null) {
|
83 |
+
return null;
|
84 |
+
}
|
85 |
+
if ($this->appSecretProof === null) {
|
86 |
+
$this->appSecretProof = \hash_hmac('sha256', $this->getAccessToken(), $this->getAppSecret());
|
87 |
+
}
|
88 |
+
return $this->appSecretProof;
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
public function getRequestParameters()
|
94 |
+
{
|
95 |
+
if ($this->getAppSecretProof() !== null) {
|
96 |
+
return array('access_token' => $this->getAccessToken(), 'appsecret_proof' => $this->getAppSecretProof());
|
97 |
+
} else {
|
98 |
+
return array('access_token' => $this->getAccessToken());
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
{vendor → third-party/vendor}/facebook/php-business-sdk/src/FacebookAds/SessionInterface.php
RENAMED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
4 |
*
|
@@ -21,13 +22,12 @@
|
|
21 |
* DEALINGS IN THE SOFTWARE.
|
22 |
*
|
23 |
*/
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function getRequestParameters();
|
33 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
5 |
*
|
22 |
* DEALINGS IN THE SOFTWARE.
|
23 |
*
|
24 |
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
|
27 |
+
interface SessionInterface
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function getRequestParameters();
|
|
|
|
|
33 |
}
|
third-party/vendor/facebook/php-business-sdk/src/FacebookAds/TypeChecker.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
5 |
+
*
|
6 |
+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
|
7 |
+
* use, copy, modify, and distribute this software in source code or binary
|
8 |
+
* form for use in connection with the web services and APIs provided by
|
9 |
+
* Facebook.
|
10 |
+
*
|
11 |
+
* As with any software that integrates with the Facebook platform, your use
|
12 |
+
* of this software is subject to the Facebook Developer Principles and
|
13 |
+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
|
14 |
+
* shall be included in all copies or substantial portions of the software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22 |
+
* DEALINGS IN THE SOFTWARE.
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
namespace PixelCaffeine\Dependencies\FacebookAds;
|
26 |
+
|
27 |
+
class TypeChecker
|
28 |
+
{
|
29 |
+
const ABSTRACT_OBJECT_PREFIX = "FacebookAds\\Object\\";
|
30 |
+
private $type_data;
|
31 |
+
private $enum_data;
|
32 |
+
private $primitive_types = ["unsigned int", "int", "bool", "string", "Object", "datetime", "float"];
|
33 |
+
public function __construct($type_check_info, $type_check_enum)
|
34 |
+
{
|
35 |
+
$this->type_data = $type_check_info;
|
36 |
+
$this->enum_data = $type_check_enum;
|
37 |
+
}
|
38 |
+
public function isPrimitiveType($param)
|
39 |
+
{
|
40 |
+
return \in_array($param, $this->primitive_types) || \array_key_exists($param, $this->enum_data);
|
41 |
+
}
|
42 |
+
public function convertStringToPrimType($primitive_type, $value)
|
43 |
+
{
|
44 |
+
if (\array_key_exists($primitive_type, $this->enum_data)) {
|
45 |
+
return $value;
|
46 |
+
} elseif (\in_array($primitive_type, array("unsigned int", "int"))) {
|
47 |
+
return \intval($value);
|
48 |
+
} elseif ($primitive_type === "bool") {
|
49 |
+
return \boolval($value);
|
50 |
+
} elseif ($primitive_type === "float") {
|
51 |
+
return \floatval($value);
|
52 |
+
} elseif ($primitive_type === "datetime") {
|
53 |
+
return $value;
|
54 |
+
} elseif ($primitive_type === "string") {
|
55 |
+
return $value;
|
56 |
+
} elseif ($primitive_type === "Object") {
|
57 |
+
return $value;
|
58 |
+
} else {
|
59 |
+
if (\PixelCaffeine\Dependencies\FacebookAds\ApiConfig::TYPE_CHECKER_STRICT_MODE) {
|
60 |
+
throw new \Exception("Not a primitive type");
|
61 |
+
} else {
|
62 |
+
return $value;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
public function getType($param)
|
67 |
+
{
|
68 |
+
if (\array_key_exists($param, $this->type_data)) {
|
69 |
+
return $this->type_data[$param];
|
70 |
+
} else {
|
71 |
+
return null;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
public function isValidParam($param)
|
75 |
+
{
|
76 |
+
return \array_key_exists($param, $this->type_data);
|
77 |
+
}
|
78 |
+
public function isValidParamPair($param, $value)
|
79 |
+
{
|
80 |
+
if ($this->isValidParam($param)) {
|
81 |
+
$type = $this->type_data[$param];
|
82 |
+
return $this->checkType($type, $value);
|
83 |
+
}
|
84 |
+
return \false;
|
85 |
+
}
|
86 |
+
public function checkType($type, $value, $allow_array_for_obj = \true)
|
87 |
+
{
|
88 |
+
if ($value === null || $type === null || $type === "Object") {
|
89 |
+
return \true;
|
90 |
+
} else {
|
91 |
+
if (\array_key_exists($type, $this->enum_data)) {
|
92 |
+
return \in_array($value, $this->enum_data[$type]);
|
93 |
+
} else {
|
94 |
+
if ($type === "file") {
|
95 |
+
return \file_exists($value);
|
96 |
+
} else {
|
97 |
+
if ($type === "list" || $type === "map") {
|
98 |
+
return \is_array($value);
|
99 |
+
} else {
|
100 |
+
if ($type === "bool") {
|
101 |
+
return \is_bool($value);
|
102 |
+
} else {
|
103 |
+
if ($type === "int" || $type === "unsigned int" || $type === "float") {
|
104 |
+
return \is_numeric($value);
|
105 |
+
} else {
|
106 |
+
if ($type === "string" || $type === "datetime") {
|
107 |
+
return \is_string($value) || \is_numeric($value) || \is_bool($value);
|
108 |
+
} else {
|
109 |
+
if ($this->isTypeCollection($type, "list")) {
|
110 |
+
$sub_types = $this->getTypeFromCollection($type, "list");
|
111 |
+
$sub_type = $sub_types[0];
|
112 |
+
if (\is_array($value)) {
|
113 |
+
if (empty($value)) {
|
114 |
+
return \true;
|
115 |
+
}
|
116 |
+
$all_object_same_type = \true;
|
117 |
+
foreach ($value as $key => $sub_value) {
|
118 |
+
$all_object_same_type = $all_object_same_type && $this->checkType($sub_type, $sub_value);
|
119 |
+
}
|
120 |
+
return $all_object_same_type;
|
121 |
+
} else {
|
122 |
+
return $this->checkType($sub_type, $value);
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
if ($this->isTypeCollection($type, "map")) {
|
126 |
+
if (\is_array($value)) {
|
127 |
+
$sub_types = $this->getTypeFromCollection($type, "map");
|
128 |
+
if (\count($sub_types) === 1) {
|
129 |
+
$sub_key_type = 'string';
|
130 |
+
$sub_value_type = $sub_types[0];
|
131 |
+
} else {
|
132 |
+
$sub_key_type = $sub_types[0];
|
133 |
+
$sub_value_type = $sub_types[1];
|
134 |
+
}
|
135 |
+
$all_object_same_type = \true;
|
136 |
+
foreach ($value as $key => $sub_value) {
|
137 |
+
$all_object_same_type = $all_object_same_type && $this->checkType($sub_key_type, $key) && $this->checkType($sub_value_type, $sub_value);
|
138 |
+
}
|
139 |
+
return $all_object_same_type;
|
140 |
+
}
|
141 |
+
} else {
|
142 |
+
// the type is an object
|
143 |
+
if ($allow_array_for_obj && \is_array($value)) {
|
144 |
+
return \true;
|
145 |
+
}
|
146 |
+
if (!$this->startsWith($type, self::ABSTRACT_OBJECT_PREFIX)) {
|
147 |
+
$type = self::ABSTRACT_OBJECT_PREFIX . $type;
|
148 |
+
}
|
149 |
+
return \is_a($value, $type);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
return \false;
|
160 |
+
}
|
161 |
+
public function isAbstractObject($value)
|
162 |
+
{
|
163 |
+
if (\is_object($value)) {
|
164 |
+
$cls_name = \get_class($value);
|
165 |
+
return $this->startsWith($cls_name, self::ABSTRACT_OBJECT_PREFIX);
|
166 |
+
}
|
167 |
+
return \false;
|
168 |
+
}
|
169 |
+
private function startsWith($string, $prefix)
|
170 |
+
{
|
171 |
+
return $prefix === "" || \strrpos($string, $prefix, -\strlen($string)) !== \false;
|
172 |
+
}
|
173 |
+
public function isListParam($param)
|
174 |
+
{
|
175 |
+
if ($this->isValidParam($param)) {
|
176 |
+
return $this->isTypeCollection($this->type_data[$param], "list");
|
177 |
+
}
|
178 |
+
return \false;
|
179 |
+
}
|
180 |
+
public function isMapParam($param)
|
181 |
+
{
|
182 |
+
if ($this->isValidParam($param)) {
|
183 |
+
return $this->isTypeCollection($this->type_data[$param], "map");
|
184 |
+
}
|
185 |
+
return \false;
|
186 |
+
}
|
187 |
+
public function isFileParam($param)
|
188 |
+
{
|
189 |
+
if ($this->isValidParam($param)) {
|
190 |
+
return $this->type_data[$param] === "file";
|
191 |
+
}
|
192 |
+
return \false;
|
193 |
+
}
|
194 |
+
public function isTypeCollection($type, $collection)
|
195 |
+
{
|
196 |
+
$len_of_collection = \strlen($collection);
|
197 |
+
$typeCollection = \substr($type, 0, $len_of_collection);
|
198 |
+
return $collection === $typeCollection;
|
199 |
+
}
|
200 |
+
public function getTypeFromCollection($type, $collection)
|
201 |
+
{
|
202 |
+
return \explode(",", \trim(\substr($type, \strlen($collection)), "<>"));
|
203 |
+
}
|
204 |
+
}
|
{vendor → third-party/vendor}/firebase/php-jwt/package.xml
RENAMED
File without changes
|
{vendor → third-party/vendor}/firebase/php-jwt/src/BeforeValidException.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
|
4 |
class BeforeValidException extends \UnexpectedValueException
|
5 |
{
|
6 |
-
|
7 |
}
|
1 |
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\Firebase\JWT;
|
4 |
|
5 |
class BeforeValidException extends \UnexpectedValueException
|
6 |
{
|
|
|
7 |
}
|
{vendor → third-party/vendor}/firebase/php-jwt/src/ExpiredException.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
|
4 |
class ExpiredException extends \UnexpectedValueException
|
5 |
{
|
6 |
-
|
7 |
}
|
1 |
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\Firebase\JWT;
|
4 |
|
5 |
class ExpiredException extends \UnexpectedValueException
|
6 |
{
|
|
|
7 |
}
|
{vendor → third-party/vendor}/firebase/php-jwt/src/JWT.php
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace Firebase\JWT;
|
4 |
-
use \DomainException;
|
5 |
-
use \InvalidArgumentException;
|
6 |
-
use \UnexpectedValueException;
|
7 |
-
use \DateTime;
|
8 |
|
|
|
|
|
|
|
|
|
9 |
/**
|
10 |
* JSON Web Token implementation, based on this spec:
|
11 |
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
|
@@ -21,14 +21,12 @@ use \DateTime;
|
|
21 |
*/
|
22 |
class JWT
|
23 |
{
|
24 |
-
|
25 |
/**
|
26 |
* When checking nbf, iat or expiration times,
|
27 |
* we want to provide some extra leeway time to
|
28 |
* account for clock skew.
|
29 |
*/
|
30 |
public static $leeway = 0;
|
31 |
-
|
32 |
/**
|
33 |
* Allow the current timestamp to be specified.
|
34 |
* Useful for fixing a value within unit testing.
|
@@ -36,14 +34,7 @@ class JWT
|
|
36 |
* Will default to PHP time() value if null.
|
37 |
*/
|
38 |
public static $timestamp = null;
|
39 |
-
|
40 |
-
public static $supported_algs = array(
|
41 |
-
'HS256' => array('hash_hmac', 'SHA256'),
|
42 |
-
'HS512' => array('hash_hmac', 'SHA512'),
|
43 |
-
'HS384' => array('hash_hmac', 'SHA384'),
|
44 |
-
'RS256' => array('openssl', 'SHA256'),
|
45 |
-
);
|
46 |
-
|
47 |
/**
|
48 |
* Decodes a JWT string into a PHP object.
|
49 |
*
|
@@ -66,74 +57,62 @@ class JWT
|
|
66 |
*/
|
67 |
public static function decode($jwt, $key, $allowed_algs = array())
|
68 |
{
|
69 |
-
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
|
70 |
-
|
71 |
if (empty($key)) {
|
72 |
-
throw new InvalidArgumentException('Key may not be empty');
|
73 |
}
|
74 |
-
if (
|
75 |
-
throw new InvalidArgumentException('Algorithm not allowed');
|
76 |
}
|
77 |
-
$tks = explode('.', $jwt);
|
78 |
-
if (count($tks) != 3) {
|
79 |
-
throw new UnexpectedValueException('Wrong number of segments');
|
80 |
}
|
81 |
list($headb64, $bodyb64, $cryptob64) = $tks;
|
82 |
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
|
83 |
-
throw new UnexpectedValueException('Invalid header encoding');
|
84 |
}
|
85 |
-
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
|
86 |
-
throw new UnexpectedValueException('Invalid claims encoding');
|
87 |
}
|
88 |
$sig = static::urlsafeB64Decode($cryptob64);
|
89 |
-
|
90 |
if (empty($header->alg)) {
|
91 |
-
throw new UnexpectedValueException('Empty algorithm');
|
92 |
}
|
93 |
if (empty(static::$supported_algs[$header->alg])) {
|
94 |
-
throw new UnexpectedValueException('Algorithm not supported');
|
95 |
}
|
96 |
-
if (
|
97 |
-
throw new UnexpectedValueException('Algorithm not allowed');
|
98 |
}
|
99 |
-
if (is_array($key) || $key instanceof \ArrayAccess) {
|
100 |
if (isset($header->kid)) {
|
101 |
$key = $key[$header->kid];
|
102 |
} else {
|
103 |
-
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
|
104 |
}
|
105 |
}
|
106 |
-
|
107 |
// Check the signature
|
108 |
-
if (!static::verify("$headb64
|
109 |
-
throw new SignatureInvalidException('Signature verification failed');
|
110 |
}
|
111 |
-
|
112 |
// Check if the nbf if it is defined. This is the time that the
|
113 |
// token can actually be used. If it's not yet that time, abort.
|
114 |
-
if (isset($payload->nbf) && $payload->nbf >
|
115 |
-
throw new BeforeValidException(
|
116 |
-
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
|
117 |
-
);
|
118 |
}
|
119 |
-
|
120 |
// Check that this token has been created before 'now'. This prevents
|
121 |
// using tokens that have been created for later use (and haven't
|
122 |
// correctly used the nbf claim).
|
123 |
-
if (isset($payload->iat) && $payload->iat >
|
124 |
-
throw new BeforeValidException(
|
125 |
-
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
|
126 |
-
);
|
127 |
}
|
128 |
-
|
129 |
// Check if this token has expired.
|
130 |
-
if (isset($payload->exp) &&
|
131 |
-
throw new ExpiredException('Expired token');
|
132 |
}
|
133 |
-
|
134 |
return $payload;
|
135 |
}
|
136 |
-
|
137 |
/**
|
138 |
* Converts and signs a PHP object or array into a JWT string.
|
139 |
*
|
@@ -156,20 +135,17 @@ class JWT
|
|
156 |
if ($keyId !== null) {
|
157 |
$header['kid'] = $keyId;
|
158 |
}
|
159 |
-
if (
|
160 |
-
$header = array_merge($head, $header);
|
161 |
}
|
162 |
$segments = array();
|
163 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
|
164 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
|
165 |
-
$signing_input = implode('.', $segments);
|
166 |
-
|
167 |
$signature = static::sign($signing_input, $key, $alg);
|
168 |
$segments[] = static::urlsafeB64Encode($signature);
|
169 |
-
|
170 |
-
return implode('.', $segments);
|
171 |
}
|
172 |
-
|
173 |
/**
|
174 |
* Sign a string with a given key and algorithm.
|
175 |
*
|
@@ -185,23 +161,22 @@ class JWT
|
|
185 |
public static function sign($msg, $key, $alg = 'HS256')
|
186 |
{
|
187 |
if (empty(static::$supported_algs[$alg])) {
|
188 |
-
throw new DomainException('Algorithm not supported');
|
189 |
}
|
190 |
list($function, $algorithm) = static::$supported_algs[$alg];
|
191 |
-
switch($function) {
|
192 |
case 'hash_hmac':
|
193 |
-
return hash_hmac($algorithm, $msg, $key, true);
|
194 |
case 'openssl':
|
195 |
$signature = '';
|
196 |
-
$success = openssl_sign($msg, $signature, $key, $algorithm);
|
197 |
if (!$success) {
|
198 |
-
throw new DomainException("OpenSSL unable to sign data");
|
199 |
} else {
|
200 |
return $signature;
|
201 |
}
|
202 |
}
|
203 |
}
|
204 |
-
|
205 |
/**
|
206 |
* Verify a signature with the message, key and method. Not all methods
|
207 |
* are symmetric, so we must have a separate verify and sign method.
|
@@ -218,36 +193,32 @@ class JWT
|
|
218 |
private static function verify($msg, $signature, $key, $alg)
|
219 |
{
|
220 |
if (empty(static::$supported_algs[$alg])) {
|
221 |
-
throw new DomainException('Algorithm not supported');
|
222 |
}
|
223 |
-
|
224 |
list($function, $algorithm) = static::$supported_algs[$alg];
|
225 |
-
switch($function) {
|
226 |
case 'openssl':
|
227 |
-
$success = openssl_verify($msg, $signature, $key, $algorithm);
|
228 |
if (!$success) {
|
229 |
-
throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string());
|
230 |
} else {
|
231 |
return $signature;
|
232 |
}
|
233 |
case 'hash_hmac':
|
234 |
default:
|
235 |
-
$hash = hash_hmac($algorithm, $msg, $key, true);
|
236 |
-
if (function_exists('hash_equals')) {
|
237 |
-
return hash_equals($signature, $hash);
|
238 |
}
|
239 |
-
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
|
240 |
-
|
241 |
$status = 0;
|
242 |
for ($i = 0; $i < $len; $i++) {
|
243 |
-
$status |=
|
244 |
}
|
245 |
-
$status |=
|
246 |
-
|
247 |
-
return ($status === 0);
|
248 |
}
|
249 |
}
|
250 |
-
|
251 |
/**
|
252 |
* Decode a JSON string into a PHP object.
|
253 |
*
|
@@ -259,30 +230,28 @@ class JWT
|
|
259 |
*/
|
260 |
public static function jsonDecode($input)
|
261 |
{
|
262 |
-
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
|
263 |
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
|
264 |
* to specify that large ints (like Steam Transaction IDs) should be treated as
|
265 |
* strings, rather than the PHP default behaviour of converting them to floats.
|
266 |
*/
|
267 |
-
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
|
268 |
} else {
|
269 |
/** Not all servers will support that, however, so for older versions we must
|
270 |
* manually detect large ints in the JSON string and quote them (thus converting
|
271 |
*them to strings) before decoding, hence the preg_replace() call.
|
272 |
*/
|
273 |
-
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
|
274 |
-
$json_without_bigints = preg_replace('
|
275 |
-
$obj = json_decode($json_without_bigints);
|
276 |
}
|
277 |
-
|
278 |
-
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
279 |
static::handleJsonError($errno);
|
280 |
} elseif ($obj === null && $input !== 'null') {
|
281 |
-
throw new DomainException('Null result with non-null input');
|
282 |
}
|
283 |
return $obj;
|
284 |
}
|
285 |
-
|
286 |
/**
|
287 |
* Encode a PHP object into a JSON string.
|
288 |
*
|
@@ -294,15 +263,14 @@ class JWT
|
|
294 |
*/
|
295 |
public static function jsonEncode($input)
|
296 |
{
|
297 |
-
$json = json_encode($input);
|
298 |
-
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
299 |
static::handleJsonError($errno);
|
300 |
} elseif ($json === 'null' && $input !== null) {
|
301 |
-
throw new DomainException('Null result with non-null input');
|
302 |
}
|
303 |
return $json;
|
304 |
}
|
305 |
-
|
306 |
/**
|
307 |
* Decode a string with URL-safe Base64.
|
308 |
*
|
@@ -312,14 +280,13 @@ class JWT
|
|
312 |
*/
|
313 |
public static function urlsafeB64Decode($input)
|
314 |
{
|
315 |
-
$remainder = strlen($input) % 4;
|
316 |
if ($remainder) {
|
317 |
$padlen = 4 - $remainder;
|
318 |
-
$input .= str_repeat('=', $padlen);
|
319 |
}
|
320 |
-
return base64_decode(strtr($input, '-_', '+/'));
|
321 |
}
|
322 |
-
|
323 |
/**
|
324 |
* Encode a string with URL-safe Base64.
|
325 |
*
|
@@ -329,9 +296,8 @@ class JWT
|
|
329 |
*/
|
330 |
public static function urlsafeB64Encode($input)
|
331 |
{
|
332 |
-
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
333 |
}
|
334 |
-
|
335 |
/**
|
336 |
* Helper method to create a JSON error.
|
337 |
*
|
@@ -341,18 +307,9 @@ class JWT
|
|
341 |
*/
|
342 |
private static function handleJsonError($errno)
|
343 |
{
|
344 |
-
$messages = array(
|
345 |
-
|
346 |
-
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
|
347 |
-
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
|
348 |
-
);
|
349 |
-
throw new DomainException(
|
350 |
-
isset($messages[$errno])
|
351 |
-
? $messages[$errno]
|
352 |
-
: 'Unknown JSON error: ' . $errno
|
353 |
-
);
|
354 |
}
|
355 |
-
|
356 |
/**
|
357 |
* Get the number of bytes in cryptographic strings.
|
358 |
*
|
@@ -362,9 +319,9 @@ class JWT
|
|
362 |
*/
|
363 |
private static function safeStrlen($str)
|
364 |
{
|
365 |
-
if (function_exists('mb_strlen')) {
|
366 |
-
return mb_strlen($str, '8bit');
|
367 |
}
|
368 |
-
return strlen($str);
|
369 |
}
|
370 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\Firebase\JWT;
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use DomainException;
|
6 |
+
use InvalidArgumentException;
|
7 |
+
use UnexpectedValueException;
|
8 |
+
use DateTime;
|
9 |
/**
|
10 |
* JSON Web Token implementation, based on this spec:
|
11 |
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
|
21 |
*/
|
22 |
class JWT
|
23 |
{
|
|
|
24 |
/**
|
25 |
* When checking nbf, iat or expiration times,
|
26 |
* we want to provide some extra leeway time to
|
27 |
* account for clock skew.
|
28 |
*/
|
29 |
public static $leeway = 0;
|
|
|
30 |
/**
|
31 |
* Allow the current timestamp to be specified.
|
32 |
* Useful for fixing a value within unit testing.
|
34 |
* Will default to PHP time() value if null.
|
35 |
*/
|
36 |
public static $timestamp = null;
|
37 |
+
public static $supported_algs = array('HS256' => array('hash_hmac', 'SHA256'), 'HS512' => array('hash_hmac', 'SHA512'), 'HS384' => array('hash_hmac', 'SHA384'), 'RS256' => array('openssl', 'SHA256'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* Decodes a JWT string into a PHP object.
|
40 |
*
|
57 |
*/
|
58 |
public static function decode($jwt, $key, $allowed_algs = array())
|
59 |
{
|
60 |
+
$timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
|
|
|
61 |
if (empty($key)) {
|
62 |
+
throw new \InvalidArgumentException('Key may not be empty');
|
63 |
}
|
64 |
+
if (!\is_array($allowed_algs)) {
|
65 |
+
throw new \InvalidArgumentException('Algorithm not allowed');
|
66 |
}
|
67 |
+
$tks = \explode('.', $jwt);
|
68 |
+
if (\count($tks) != 3) {
|
69 |
+
throw new \UnexpectedValueException('Wrong number of segments');
|
70 |
}
|
71 |
list($headb64, $bodyb64, $cryptob64) = $tks;
|
72 |
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
|
73 |
+
throw new \UnexpectedValueException('Invalid header encoding');
|
74 |
}
|
75 |
+
if (null === ($payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64)))) {
|
76 |
+
throw new \UnexpectedValueException('Invalid claims encoding');
|
77 |
}
|
78 |
$sig = static::urlsafeB64Decode($cryptob64);
|
|
|
79 |
if (empty($header->alg)) {
|
80 |
+
throw new \UnexpectedValueException('Empty algorithm');
|
81 |
}
|
82 |
if (empty(static::$supported_algs[$header->alg])) {
|
83 |
+
throw new \UnexpectedValueException('Algorithm not supported');
|
84 |
}
|
85 |
+
if (!\in_array($header->alg, $allowed_algs)) {
|
86 |
+
throw new \UnexpectedValueException('Algorithm not allowed');
|
87 |
}
|
88 |
+
if (\is_array($key) || $key instanceof \ArrayAccess) {
|
89 |
if (isset($header->kid)) {
|
90 |
$key = $key[$header->kid];
|
91 |
} else {
|
92 |
+
throw new \UnexpectedValueException('"kid" empty, unable to lookup correct key');
|
93 |
}
|
94 |
}
|
|
|
95 |
// Check the signature
|
96 |
+
if (!static::verify("{$headb64}.{$bodyb64}", $sig, $key, $header->alg)) {
|
97 |
+
throw new \PixelCaffeine\Dependencies\Firebase\JWT\SignatureInvalidException('Signature verification failed');
|
98 |
}
|
|
|
99 |
// Check if the nbf if it is defined. This is the time that the
|
100 |
// token can actually be used. If it's not yet that time, abort.
|
101 |
+
if (isset($payload->nbf) && $payload->nbf > $timestamp + static::$leeway) {
|
102 |
+
throw new \PixelCaffeine\Dependencies\Firebase\JWT\BeforeValidException('Cannot handle token prior to ' . \date(\DateTime::ISO8601, $payload->nbf));
|
|
|
|
|
103 |
}
|
|
|
104 |
// Check that this token has been created before 'now'. This prevents
|
105 |
// using tokens that have been created for later use (and haven't
|
106 |
// correctly used the nbf claim).
|
107 |
+
if (isset($payload->iat) && $payload->iat > $timestamp + static::$leeway) {
|
108 |
+
throw new \PixelCaffeine\Dependencies\Firebase\JWT\BeforeValidException('Cannot handle token prior to ' . \date(\DateTime::ISO8601, $payload->iat));
|
|
|
|
|
109 |
}
|
|
|
110 |
// Check if this token has expired.
|
111 |
+
if (isset($payload->exp) && $timestamp - static::$leeway >= $payload->exp) {
|
112 |
+
throw new \PixelCaffeine\Dependencies\Firebase\JWT\ExpiredException('Expired token');
|
113 |
}
|
|
|
114 |
return $payload;
|
115 |
}
|
|
|
116 |
/**
|
117 |
* Converts and signs a PHP object or array into a JWT string.
|
118 |
*
|
135 |
if ($keyId !== null) {
|
136 |
$header['kid'] = $keyId;
|
137 |
}
|
138 |
+
if (isset($head) && \is_array($head)) {
|
139 |
+
$header = \array_merge($head, $header);
|
140 |
}
|
141 |
$segments = array();
|
142 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
|
143 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
|
144 |
+
$signing_input = \implode('.', $segments);
|
|
|
145 |
$signature = static::sign($signing_input, $key, $alg);
|
146 |
$segments[] = static::urlsafeB64Encode($signature);
|
147 |
+
return \implode('.', $segments);
|
|
|
148 |
}
|
|
|
149 |
/**
|
150 |
* Sign a string with a given key and algorithm.
|
151 |
*
|
161 |
public static function sign($msg, $key, $alg = 'HS256')
|
162 |
{
|
163 |
if (empty(static::$supported_algs[$alg])) {
|
164 |
+
throw new \DomainException('Algorithm not supported');
|
165 |
}
|
166 |
list($function, $algorithm) = static::$supported_algs[$alg];
|
167 |
+
switch ($function) {
|
168 |
case 'hash_hmac':
|
169 |
+
return \hash_hmac($algorithm, $msg, $key, \true);
|
170 |
case 'openssl':
|
171 |
$signature = '';
|
172 |
+
$success = \openssl_sign($msg, $signature, $key, $algorithm);
|
173 |
if (!$success) {
|
174 |
+
throw new \DomainException("OpenSSL unable to sign data");
|
175 |
} else {
|
176 |
return $signature;
|
177 |
}
|
178 |
}
|
179 |
}
|
|
|
180 |
/**
|
181 |
* Verify a signature with the message, key and method. Not all methods
|
182 |
* are symmetric, so we must have a separate verify and sign method.
|
193 |
private static function verify($msg, $signature, $key, $alg)
|
194 |
{
|
195 |
if (empty(static::$supported_algs[$alg])) {
|
196 |
+
throw new \DomainException('Algorithm not supported');
|
197 |
}
|
|
|
198 |
list($function, $algorithm) = static::$supported_algs[$alg];
|
199 |
+
switch ($function) {
|
200 |
case 'openssl':
|
201 |
+
$success = \openssl_verify($msg, $signature, $key, $algorithm);
|
202 |
if (!$success) {
|
203 |
+
throw new \DomainException("OpenSSL unable to verify data: " . \openssl_error_string());
|
204 |
} else {
|
205 |
return $signature;
|
206 |
}
|
207 |
case 'hash_hmac':
|
208 |
default:
|
209 |
+
$hash = \hash_hmac($algorithm, $msg, $key, \true);
|
210 |
+
if (\function_exists('hash_equals')) {
|
211 |
+
return \hash_equals($signature, $hash);
|
212 |
}
|
213 |
+
$len = \min(static::safeStrlen($signature), static::safeStrlen($hash));
|
|
|
214 |
$status = 0;
|
215 |
for ($i = 0; $i < $len; $i++) {
|
216 |
+
$status |= \ord($signature[$i]) ^ \ord($hash[$i]);
|
217 |
}
|
218 |
+
$status |= static::safeStrlen($signature) ^ static::safeStrlen($hash);
|
219 |
+
return $status === 0;
|
|
|
220 |
}
|
221 |
}
|
|
|
222 |
/**
|
223 |
* Decode a JSON string into a PHP object.
|
224 |
*
|
230 |
*/
|
231 |
public static function jsonDecode($input)
|
232 |
{
|
233 |
+
if (\version_compare(\PHP_VERSION, '5.4.0', '>=') && !(\defined('PixelCaffeine\\Dependencies\\JSON_C_VERSION') && \PHP_INT_SIZE > 4)) {
|
234 |
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
|
235 |
* to specify that large ints (like Steam Transaction IDs) should be treated as
|
236 |
* strings, rather than the PHP default behaviour of converting them to floats.
|
237 |
*/
|
238 |
+
$obj = \json_decode($input, \false, 512, \JSON_BIGINT_AS_STRING);
|
239 |
} else {
|
240 |
/** Not all servers will support that, however, so for older versions we must
|
241 |
* manually detect large ints in the JSON string and quote them (thus converting
|
242 |
*them to strings) before decoding, hence the preg_replace() call.
|
243 |
*/
|
244 |
+
$max_int_length = \strlen((string) \PHP_INT_MAX) - 1;
|
245 |
+
$json_without_bigints = \preg_replace('/:\\s*(-?\\d{' . $max_int_length . ',})/', ': "$1"', $input);
|
246 |
+
$obj = \json_decode($json_without_bigints);
|
247 |
}
|
248 |
+
if (\function_exists('json_last_error') && ($errno = \json_last_error())) {
|
|
|
249 |
static::handleJsonError($errno);
|
250 |
} elseif ($obj === null && $input !== 'null') {
|
251 |
+
throw new \DomainException('Null result with non-null input');
|
252 |
}
|
253 |
return $obj;
|
254 |
}
|
|
|
255 |
/**
|
256 |
* Encode a PHP object into a JSON string.
|
257 |
*
|
263 |
*/
|
264 |
public static function jsonEncode($input)
|
265 |
{
|
266 |
+
$json = \json_encode($input);
|
267 |
+
if (\function_exists('json_last_error') && ($errno = \json_last_error())) {
|
268 |
static::handleJsonError($errno);
|
269 |
} elseif ($json === 'null' && $input !== null) {
|
270 |
+
throw new \DomainException('Null result with non-null input');
|
271 |
}
|
272 |
return $json;
|
273 |
}
|
|
|
274 |
/**
|
275 |
* Decode a string with URL-safe Base64.
|
276 |
*
|
280 |
*/
|
281 |
public static function urlsafeB64Decode($input)
|
282 |
{
|
283 |
+
$remainder = \strlen($input) % 4;
|
284 |
if ($remainder) {
|
285 |
$padlen = 4 - $remainder;
|
286 |
+
$input .= \str_repeat('=', $padlen);
|
287 |
}
|
288 |
+
return \base64_decode(\strtr($input, '-_', '+/'));
|
289 |
}
|
|
|
290 |
/**
|
291 |
* Encode a string with URL-safe Base64.
|
292 |
*
|
296 |
*/
|
297 |
public static function urlsafeB64Encode($input)
|
298 |
{
|
299 |
+
return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
|
300 |
}
|
|
|
301 |
/**
|
302 |
* Helper method to create a JSON error.
|
303 |
*
|
307 |
*/
|
308 |
private static function handleJsonError($errno)
|
309 |
{
|
310 |
+
$messages = array(\JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', \JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', \JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON');
|
311 |
+
throw new \DomainException(isset($messages[$errno]) ? $messages[$errno] : 'Unknown JSON error: ' . $errno);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
}
|
|
|
313 |
/**
|
314 |
* Get the number of bytes in cryptographic strings.
|
315 |
*
|
319 |
*/
|
320 |
private static function safeStrlen($str)
|
321 |
{
|
322 |
+
if (\function_exists('mb_strlen')) {
|
323 |
+
return \mb_strlen($str, '8bit');
|
324 |
}
|
325 |
+
return \strlen($str);
|
326 |
}
|
327 |
}
|
{vendor → third-party/vendor}/firebase/php-jwt/src/SignatureInvalidException.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
|
4 |
class SignatureInvalidException extends \UnexpectedValueException
|
5 |
{
|
6 |
-
|
7 |
}
|
1 |
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\Firebase\JWT;
|
4 |
|
5 |
class SignatureInvalidException extends \UnexpectedValueException
|
6 |
{
|
|
|
7 |
}
|
third-party/vendor/guzzlehttp/guzzle/Dockerfile
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM composer:latest as setup
|
2 |
+
|
3 |
+
RUN mkdir /guzzle
|
4 |
+
|
5 |
+
WORKDIR /guzzle
|
6 |
+
|
7 |
+
RUN set -xe \
|
8 |
+
&& composer init --name=guzzlehttp/test --description="Simple project for testing Guzzle scripts" --author="Márk Sági-Kazár <mark.sagikazar@gmail.com>" --no-interaction \
|
9 |
+
&& composer require guzzlehttp/guzzle
|
10 |
+
|
11 |
+
|
12 |
+
FROM php:7.3
|
13 |
+
|
14 |
+
RUN mkdir /guzzle
|
15 |
+
|
16 |
+
WORKDIR /guzzle
|
17 |
+
|
18 |
+
COPY --from=setup /guzzle /guzzle
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Client.php
RENAMED
@@ -1,28 +1,32 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use GuzzleHttp\Cookie\CookieJar;
|
6 |
-
use GuzzleHttp\Exception\GuzzleException;
|
7 |
-
use GuzzleHttp\
|
8 |
-
use GuzzleHttp\
|
9 |
-
use
|
10 |
-
use Psr\Http\Message\
|
11 |
-
use Psr\Http\Message\
|
12 |
-
use Psr\Http\Message\UriInterface;
|
13 |
-
|
14 |
/**
|
15 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
-
class Client implements
|
18 |
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @var array Default request options
|
23 |
-
*/
|
24 |
private $config;
|
25 |
-
|
26 |
/**
|
27 |
* Clients accept an array of constructor parameters.
|
28 |
*
|
@@ -57,86 +61,59 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
57 |
public function __construct(array $config = [])
|
58 |
{
|
59 |
if (!isset($config['handler'])) {
|
60 |
-
$config['handler'] = HandlerStack::create();
|
61 |
} elseif (!\is_callable($config['handler'])) {
|
62 |
-
throw new InvalidArgumentException('handler must be a callable');
|
63 |
}
|
64 |
-
|
65 |
// Convert the base_uri to a UriInterface
|
66 |
if (isset($config['base_uri'])) {
|
67 |
-
$config['base_uri'] = Psr7\
|
68 |
}
|
69 |
-
|
70 |
$this->configureDefaults($config);
|
71 |
}
|
72 |
-
|
73 |
/**
|
74 |
* @param string $method
|
75 |
* @param array $args
|
76 |
*
|
77 |
-
* @return PromiseInterface
|
78 |
-
*
|
79 |
-
* @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0.
|
80 |
*/
|
81 |
public function __call($method, $args)
|
82 |
{
|
83 |
if (\count($args) < 1) {
|
84 |
-
throw new InvalidArgumentException('Magic request methods require a URI and optional options array');
|
85 |
}
|
86 |
-
|
87 |
$uri = $args[0];
|
88 |
-
$opts = $args[1]
|
89 |
-
|
90 |
-
return \substr($method, -5) === 'Async'
|
91 |
-
? $this->requestAsync(\substr($method, 0, -5), $uri, $opts)
|
92 |
-
: $this->request($method, $uri, $opts);
|
93 |
}
|
94 |
-
|
95 |
/**
|
96 |
* Asynchronously send an HTTP request.
|
97 |
*
|
98 |
* @param array $options Request options to apply to the given
|
99 |
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
|
|
|
|
100 |
*/
|
101 |
-
public function sendAsync(RequestInterface $request, array $options = [])
|
102 |
{
|
103 |
// Merge the base URI into the request URI if needed.
|
104 |
$options = $this->prepareDefaults($options);
|
105 |
-
|
106 |
-
return $this->transfer(
|
107 |
-
$request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
|
108 |
-
$options
|
109 |
-
);
|
110 |
}
|
111 |
-
|
112 |
/**
|
113 |
* Send an HTTP request.
|
114 |
*
|
115 |
* @param array $options Request options to apply to the given
|
116 |
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
117 |
*
|
|
|
118 |
* @throws GuzzleException
|
119 |
*/
|
120 |
-
public function send(RequestInterface $request, array $options = [])
|
121 |
{
|
122 |
-
$options[RequestOptions::SYNCHRONOUS] = true;
|
123 |
return $this->sendAsync($request, $options)->wait();
|
124 |
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* The HttpClient PSR (PSR-18) specify this method.
|
128 |
-
*
|
129 |
-
* @inheritDoc
|
130 |
-
*/
|
131 |
-
public function sendRequest(RequestInterface $request): ResponseInterface
|
132 |
-
{
|
133 |
-
$options[RequestOptions::SYNCHRONOUS] = true;
|
134 |
-
$options[RequestOptions::ALLOW_REDIRECTS] = false;
|
135 |
-
$options[RequestOptions::HTTP_ERRORS] = false;
|
136 |
-
|
137 |
-
return $this->sendAsync($request, $options)->wait();
|
138 |
-
}
|
139 |
-
|
140 |
/**
|
141 |
* Create and send an asynchronous HTTP request.
|
142 |
*
|
@@ -148,26 +125,26 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
148 |
* @param string $method HTTP method
|
149 |
* @param string|UriInterface $uri URI object or string.
|
150 |
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
|
|
|
|
151 |
*/
|
152 |
-
public function requestAsync(
|
153 |
{
|
154 |
$options = $this->prepareDefaults($options);
|
155 |
// Remove request modifying parameter because it can be done up-front.
|
156 |
-
$headers = $options['headers']
|
157 |
-
$body = $options['body']
|
158 |
-
$version = $options['version']
|
159 |
// Merge the URI into the base URI.
|
160 |
-
$uri = $this->buildUri(
|
161 |
if (\is_array($body)) {
|
162 |
-
|
163 |
}
|
164 |
-
$request = new Psr7\Request($method, $uri, $headers, $body, $version);
|
165 |
// Remove the option so that they are not doubly-applied.
|
166 |
unset($options['headers'], $options['body'], $options['version']);
|
167 |
-
|
168 |
return $this->transfer($request, $options);
|
169 |
}
|
170 |
-
|
171 |
/**
|
172 |
* Create and send an HTTP request.
|
173 |
*
|
@@ -179,14 +156,14 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
179 |
* @param string|UriInterface $uri URI object or string.
|
180 |
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
181 |
*
|
|
|
182 |
* @throws GuzzleException
|
183 |
*/
|
184 |
-
public function request(
|
185 |
{
|
186 |
-
$options[RequestOptions::SYNCHRONOUS] = true;
|
187 |
return $this->requestAsync($method, $uri, $options)->wait();
|
188 |
}
|
189 |
-
|
190 |
/**
|
191 |
* Get a client configuration option.
|
192 |
*
|
@@ -197,71 +174,59 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
197 |
* @param string|null $option The config option to retrieve.
|
198 |
*
|
199 |
* @return mixed
|
200 |
-
*
|
201 |
-
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
202 |
*/
|
203 |
-
public function getConfig(
|
204 |
{
|
205 |
-
return $option === null
|
206 |
-
? $this->config
|
207 |
-
: (isset($this->config[$option]) ? $this->config[$option] : null);
|
208 |
}
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
211 |
{
|
|
|
|
|
212 |
if (isset($config['base_uri'])) {
|
213 |
-
$uri = Psr7\UriResolver::resolve(Psr7\
|
214 |
}
|
215 |
-
|
216 |
-
|
217 |
-
$
|
218 |
-
$uri = Utils::idnUriConvert($uri, $idnOptions);
|
219 |
}
|
220 |
-
|
221 |
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
|
222 |
}
|
223 |
-
|
224 |
/**
|
225 |
* Configures the default options for a client.
|
|
|
|
|
|
|
226 |
*/
|
227 |
-
private function configureDefaults(array $config)
|
228 |
{
|
229 |
-
$defaults = [
|
230 |
-
'allow_redirects' => RedirectMiddleware::$defaultSettings,
|
231 |
-
'http_errors' => true,
|
232 |
-
'decode_content' => true,
|
233 |
-
'verify' => true,
|
234 |
-
'cookies' => false,
|
235 |
-
'idn_conversion' => false,
|
236 |
-
];
|
237 |
-
|
238 |
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
239 |
-
|
240 |
// We can only trust the HTTP_PROXY environment variable in a CLI
|
241 |
// process due to the fact that PHP has no reliable mechanism to
|
242 |
// get environment variables that start with "HTTP_".
|
243 |
-
if (\
|
244 |
-
$defaults['proxy']['http'] =
|
245 |
}
|
246 |
-
|
247 |
-
if ($proxy = Utils::getenv('HTTPS_PROXY')) {
|
248 |
$defaults['proxy']['https'] = $proxy;
|
249 |
}
|
250 |
-
|
251 |
-
if ($noProxy = Utils::getenv('NO_PROXY')) {
|
252 |
$cleanedNoProxy = \str_replace(' ', '', $noProxy);
|
253 |
$defaults['proxy']['no'] = \explode(',', $cleanedNoProxy);
|
254 |
}
|
255 |
-
|
256 |
$this->config = $config + $defaults;
|
257 |
-
|
258 |
-
|
259 |
-
$this->config['cookies'] = new CookieJar();
|
260 |
}
|
261 |
-
|
262 |
// Add the default user-agent header.
|
263 |
if (!isset($this->config['headers'])) {
|
264 |
-
$this->config['headers'] = ['User-Agent' =>
|
265 |
} else {
|
266 |
// Add the User-Agent header if one was not already set.
|
267 |
foreach (\array_keys($this->config['headers']) as $name) {
|
@@ -269,25 +234,24 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
269 |
return;
|
270 |
}
|
271 |
}
|
272 |
-
$this->config['headers']['User-Agent'] =
|
273 |
}
|
274 |
}
|
275 |
-
|
276 |
/**
|
277 |
* Merges default options into the array.
|
278 |
*
|
279 |
* @param array $options Options to modify by reference
|
|
|
|
|
280 |
*/
|
281 |
-
private function prepareDefaults(array $options)
|
282 |
{
|
283 |
$defaults = $this->config;
|
284 |
-
|
285 |
if (!empty($defaults['headers'])) {
|
286 |
// Default headers are only added if they are not present.
|
287 |
$defaults['_conditional'] = $defaults['headers'];
|
288 |
unset($defaults['headers']);
|
289 |
}
|
290 |
-
|
291 |
// Special handling for headers is required as they are added as
|
292 |
// conditional headers and as headers passed to a request ctor.
|
293 |
if (\array_key_exists('headers', $options)) {
|
@@ -296,23 +260,19 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
296 |
$defaults['_conditional'] = [];
|
297 |
unset($options['headers']);
|
298 |
} elseif (!\is_array($options['headers'])) {
|
299 |
-
throw new InvalidArgumentException('headers must be an array');
|
300 |
}
|
301 |
}
|
302 |
-
|
303 |
// Shallow merge defaults underneath options.
|
304 |
$result = $options + $defaults;
|
305 |
-
|
306 |
// Remove null values.
|
307 |
foreach ($result as $k => $v) {
|
308 |
if ($v === null) {
|
309 |
unset($result[$k]);
|
310 |
}
|
311 |
}
|
312 |
-
|
313 |
return $result;
|
314 |
}
|
315 |
-
|
316 |
/**
|
317 |
* Transfers the given request and applies request options.
|
318 |
*
|
@@ -320,129 +280,123 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
320 |
* as-is without merging in default options.
|
321 |
*
|
322 |
* @param array $options See \GuzzleHttp\RequestOptions.
|
|
|
|
|
323 |
*/
|
324 |
-
private function transfer(RequestInterface $request, array $options)
|
325 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
$request = $this->applyOptions($request, $options);
|
327 |
/** @var HandlerStack $handler */
|
328 |
$handler = $options['handler'];
|
329 |
-
|
330 |
try {
|
331 |
-
return
|
332 |
} catch (\Exception $e) {
|
333 |
-
return
|
334 |
}
|
335 |
}
|
336 |
-
|
337 |
/**
|
338 |
* Applies the array of request options to a request.
|
|
|
|
|
|
|
|
|
|
|
339 |
*/
|
340 |
-
private function applyOptions(RequestInterface $request, array &$options)
|
341 |
{
|
342 |
-
$modify = [
|
343 |
-
'set_headers' => [],
|
344 |
-
];
|
345 |
-
|
346 |
if (isset($options['headers'])) {
|
347 |
$modify['set_headers'] = $options['headers'];
|
348 |
unset($options['headers']);
|
349 |
}
|
350 |
-
|
351 |
if (isset($options['form_params'])) {
|
352 |
if (isset($options['multipart'])) {
|
353 |
-
throw new InvalidArgumentException('You cannot use '
|
354 |
-
. 'form_params and multipart at the same time. Use the '
|
355 |
-
. 'form_params option if you want to send application/'
|
356 |
-
. 'x-www-form-urlencoded requests, and the multipart '
|
357 |
-
. 'option to send multipart/form-data requests.');
|
358 |
}
|
359 |
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
360 |
unset($options['form_params']);
|
361 |
// Ensure that we don't have the header in different case and set the new value.
|
362 |
-
$options['_conditional'] = Psr7\
|
363 |
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
364 |
}
|
365 |
-
|
366 |
if (isset($options['multipart'])) {
|
367 |
-
$options['body'] = new Psr7\MultipartStream($options['multipart']);
|
368 |
unset($options['multipart']);
|
369 |
}
|
370 |
-
|
371 |
if (isset($options['json'])) {
|
372 |
-
$options['body'] =
|
373 |
unset($options['json']);
|
374 |
// Ensure that we don't have the header in different case and set the new value.
|
375 |
-
$options['_conditional'] = Psr7\
|
376 |
$options['_conditional']['Content-Type'] = 'application/json';
|
377 |
}
|
378 |
-
|
379 |
-
if (!empty($options['decode_content'])
|
380 |
-
&& $options['decode_content'] !== true
|
381 |
-
) {
|
382 |
// Ensure that we don't have the header in different case and set the new value.
|
383 |
-
$options['_conditional'] = Psr7\
|
384 |
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
385 |
}
|
386 |
-
|
387 |
if (isset($options['body'])) {
|
388 |
if (\is_array($options['body'])) {
|
389 |
-
|
390 |
}
|
391 |
-
$modify['body'] = Psr7\
|
392 |
unset($options['body']);
|
393 |
}
|
394 |
-
|
395 |
if (!empty($options['auth']) && \is_array($options['auth'])) {
|
396 |
$value = $options['auth'];
|
397 |
$type = isset($value[2]) ? \strtolower($value[2]) : 'basic';
|
398 |
switch ($type) {
|
399 |
case 'basic':
|
400 |
// Ensure that we don't have the header in different case and set the new value.
|
401 |
-
$modify['set_headers'] = Psr7\
|
402 |
-
$modify['set_headers']['Authorization'] = 'Basic '
|
403 |
-
. \base64_encode("$value[0]:$value[1]");
|
404 |
break;
|
405 |
case 'digest':
|
406 |
// @todo: Do not rely on curl
|
407 |
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST;
|
408 |
-
$options['curl'][\CURLOPT_USERPWD] = "$value[0]
|
409 |
break;
|
410 |
case 'ntlm':
|
411 |
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM;
|
412 |
-
$options['curl'][\CURLOPT_USERPWD] = "$value[0]
|
413 |
break;
|
414 |
}
|
415 |
}
|
416 |
-
|
417 |
if (isset($options['query'])) {
|
418 |
$value = $options['query'];
|
419 |
if (\is_array($value)) {
|
420 |
-
$value = \http_build_query($value,
|
421 |
}
|
422 |
if (!\is_string($value)) {
|
423 |
-
throw new InvalidArgumentException('query must be a string or array');
|
424 |
}
|
425 |
$modify['query'] = $value;
|
426 |
unset($options['query']);
|
427 |
}
|
428 |
-
|
429 |
// Ensure that sink is not an invalid value.
|
430 |
if (isset($options['sink'])) {
|
431 |
// TODO: Add more sink validation?
|
432 |
if (\is_bool($options['sink'])) {
|
433 |
-
throw new InvalidArgumentException('sink must not be a boolean');
|
434 |
}
|
435 |
}
|
436 |
-
|
437 |
-
$request
|
438 |
-
if ($request->getBody() instanceof Psr7\MultipartStream) {
|
439 |
// Use a multipart/form-data POST if a Content-Type is not set.
|
440 |
// Ensure that we don't have the header in different case and set the new value.
|
441 |
-
$options['_conditional'] = Psr7\
|
442 |
-
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
|
443 |
-
. $request->getBody()->getBoundary();
|
444 |
}
|
445 |
-
|
446 |
// Merge in conditional headers if they are not present.
|
447 |
if (isset($options['_conditional'])) {
|
448 |
// Build up the changes so it's in a single clone of the message.
|
@@ -452,23 +406,19 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
|
452 |
$modify['set_headers'][$k] = $v;
|
453 |
}
|
454 |
}
|
455 |
-
$request = Psr7\
|
456 |
// Don't pass this internal value along to middleware/handlers.
|
457 |
unset($options['_conditional']);
|
458 |
}
|
459 |
-
|
460 |
return $request;
|
461 |
}
|
462 |
-
|
463 |
/**
|
464 |
-
*
|
|
|
|
|
465 |
*/
|
466 |
-
private function invalidBody()
|
467 |
{
|
468 |
-
|
469 |
-
. 'option as an array to send a request is not supported. '
|
470 |
-
. 'Please use the "form_params" request option to send a '
|
471 |
-
. 'application/x-www-form-urlencoded request, or the "multipart" '
|
472 |
-
. 'request option to send a multipart/form-data request.');
|
473 |
}
|
474 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\GuzzleException;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
10 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
11 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
|
|
|
|
12 |
/**
|
13 |
+
* @method ResponseInterface get(string|UriInterface $uri, array $options = [])
|
14 |
+
* @method ResponseInterface head(string|UriInterface $uri, array $options = [])
|
15 |
+
* @method ResponseInterface put(string|UriInterface $uri, array $options = [])
|
16 |
+
* @method ResponseInterface post(string|UriInterface $uri, array $options = [])
|
17 |
+
* @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
|
18 |
+
* @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
|
19 |
+
* @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
|
20 |
+
* @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
|
21 |
+
* @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
|
22 |
+
* @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
|
23 |
+
* @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
|
24 |
+
* @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
|
25 |
*/
|
26 |
+
class Client implements \PixelCaffeine\Dependencies\GuzzleHttp\ClientInterface
|
27 |
{
|
28 |
+
/** @var array Default request options */
|
|
|
|
|
|
|
|
|
29 |
private $config;
|
|
|
30 |
/**
|
31 |
* Clients accept an array of constructor parameters.
|
32 |
*
|
61 |
public function __construct(array $config = [])
|
62 |
{
|
63 |
if (!isset($config['handler'])) {
|
64 |
+
$config['handler'] = \PixelCaffeine\Dependencies\GuzzleHttp\HandlerStack::create();
|
65 |
} elseif (!\is_callable($config['handler'])) {
|
66 |
+
throw new \InvalidArgumentException('handler must be a callable');
|
67 |
}
|
|
|
68 |
// Convert the base_uri to a UriInterface
|
69 |
if (isset($config['base_uri'])) {
|
70 |
+
$config['base_uri'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\uri_for($config['base_uri']);
|
71 |
}
|
|
|
72 |
$this->configureDefaults($config);
|
73 |
}
|
|
|
74 |
/**
|
75 |
* @param string $method
|
76 |
* @param array $args
|
77 |
*
|
78 |
+
* @return Promise\PromiseInterface
|
|
|
|
|
79 |
*/
|
80 |
public function __call($method, $args)
|
81 |
{
|
82 |
if (\count($args) < 1) {
|
83 |
+
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
|
84 |
}
|
|
|
85 |
$uri = $args[0];
|
86 |
+
$opts = isset($args[1]) ? $args[1] : [];
|
87 |
+
return \substr($method, -5) === 'Async' ? $this->requestAsync(\substr($method, 0, -5), $uri, $opts) : $this->request($method, $uri, $opts);
|
|
|
|
|
|
|
88 |
}
|
|
|
89 |
/**
|
90 |
* Asynchronously send an HTTP request.
|
91 |
*
|
92 |
* @param array $options Request options to apply to the given
|
93 |
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
94 |
+
*
|
95 |
+
* @return Promise\PromiseInterface
|
96 |
*/
|
97 |
+
public function sendAsync(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options = [])
|
98 |
{
|
99 |
// Merge the base URI into the request URI if needed.
|
100 |
$options = $this->prepareDefaults($options);
|
101 |
+
return $this->transfer($request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), $options);
|
|
|
|
|
|
|
|
|
102 |
}
|
|
|
103 |
/**
|
104 |
* Send an HTTP request.
|
105 |
*
|
106 |
* @param array $options Request options to apply to the given
|
107 |
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
108 |
*
|
109 |
+
* @return ResponseInterface
|
110 |
* @throws GuzzleException
|
111 |
*/
|
112 |
+
public function send(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options = [])
|
113 |
{
|
114 |
+
$options[\PixelCaffeine\Dependencies\GuzzleHttp\RequestOptions::SYNCHRONOUS] = \true;
|
115 |
return $this->sendAsync($request, $options)->wait();
|
116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
/**
|
118 |
* Create and send an asynchronous HTTP request.
|
119 |
*
|
125 |
* @param string $method HTTP method
|
126 |
* @param string|UriInterface $uri URI object or string.
|
127 |
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
128 |
+
*
|
129 |
+
* @return Promise\PromiseInterface
|
130 |
*/
|
131 |
+
public function requestAsync($method, $uri = '', array $options = [])
|
132 |
{
|
133 |
$options = $this->prepareDefaults($options);
|
134 |
// Remove request modifying parameter because it can be done up-front.
|
135 |
+
$headers = isset($options['headers']) ? $options['headers'] : [];
|
136 |
+
$body = isset($options['body']) ? $options['body'] : null;
|
137 |
+
$version = isset($options['version']) ? $options['version'] : '1.1';
|
138 |
// Merge the URI into the base URI.
|
139 |
+
$uri = $this->buildUri($uri, $options);
|
140 |
if (\is_array($body)) {
|
141 |
+
$this->invalidBody();
|
142 |
}
|
143 |
+
$request = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Request($method, $uri, $headers, $body, $version);
|
144 |
// Remove the option so that they are not doubly-applied.
|
145 |
unset($options['headers'], $options['body'], $options['version']);
|
|
|
146 |
return $this->transfer($request, $options);
|
147 |
}
|
|
|
148 |
/**
|
149 |
* Create and send an HTTP request.
|
150 |
*
|
156 |
* @param string|UriInterface $uri URI object or string.
|
157 |
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
158 |
*
|
159 |
+
* @return ResponseInterface
|
160 |
* @throws GuzzleException
|
161 |
*/
|
162 |
+
public function request($method, $uri = '', array $options = [])
|
163 |
{
|
164 |
+
$options[\PixelCaffeine\Dependencies\GuzzleHttp\RequestOptions::SYNCHRONOUS] = \true;
|
165 |
return $this->requestAsync($method, $uri, $options)->wait();
|
166 |
}
|
|
|
167 |
/**
|
168 |
* Get a client configuration option.
|
169 |
*
|
174 |
* @param string|null $option The config option to retrieve.
|
175 |
*
|
176 |
* @return mixed
|
|
|
|
|
177 |
*/
|
178 |
+
public function getConfig($option = null)
|
179 |
{
|
180 |
+
return $option === null ? $this->config : (isset($this->config[$option]) ? $this->config[$option] : null);
|
|
|
|
|
181 |
}
|
182 |
+
/**
|
183 |
+
* @param string|null $uri
|
184 |
+
*
|
185 |
+
* @return UriInterface
|
186 |
+
*/
|
187 |
+
private function buildUri($uri, array $config)
|
188 |
{
|
189 |
+
// for BC we accept null which would otherwise fail in uri_for
|
190 |
+
$uri = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\uri_for($uri === null ? '' : $uri);
|
191 |
if (isset($config['base_uri'])) {
|
192 |
+
$uri = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::resolve(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\uri_for($config['base_uri']), $uri);
|
193 |
}
|
194 |
+
if (isset($config['idn_conversion']) && $config['idn_conversion'] !== \false) {
|
195 |
+
$idnOptions = $config['idn_conversion'] === \true ? \IDNA_DEFAULT : $config['idn_conversion'];
|
196 |
+
$uri = \PixelCaffeine\Dependencies\GuzzleHttp\Utils::idnUriConvert($uri, $idnOptions);
|
|
|
197 |
}
|
|
|
198 |
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
|
199 |
}
|
|
|
200 |
/**
|
201 |
* Configures the default options for a client.
|
202 |
+
*
|
203 |
+
* @param array $config
|
204 |
+
* @return void
|
205 |
*/
|
206 |
+
private function configureDefaults(array $config)
|
207 |
{
|
208 |
+
$defaults = ['allow_redirects' => \PixelCaffeine\Dependencies\GuzzleHttp\RedirectMiddleware::$defaultSettings, 'http_errors' => \true, 'decode_content' => \true, 'verify' => \true, 'cookies' => \false, 'idn_conversion' => \true];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
|
|
210 |
// We can only trust the HTTP_PROXY environment variable in a CLI
|
211 |
// process due to the fact that PHP has no reliable mechanism to
|
212 |
// get environment variables that start with "HTTP_".
|
213 |
+
if (\php_sapi_name() === 'cli' && \getenv('HTTP_PROXY')) {
|
214 |
+
$defaults['proxy']['http'] = \getenv('HTTP_PROXY');
|
215 |
}
|
216 |
+
if ($proxy = \getenv('HTTPS_PROXY')) {
|
|
|
217 |
$defaults['proxy']['https'] = $proxy;
|
218 |
}
|
219 |
+
if ($noProxy = \getenv('NO_PROXY')) {
|
|
|
220 |
$cleanedNoProxy = \str_replace(' ', '', $noProxy);
|
221 |
$defaults['proxy']['no'] = \explode(',', $cleanedNoProxy);
|
222 |
}
|
|
|
223 |
$this->config = $config + $defaults;
|
224 |
+
if (!empty($config['cookies']) && $config['cookies'] === \true) {
|
225 |
+
$this->config['cookies'] = new \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar();
|
|
|
226 |
}
|
|
|
227 |
// Add the default user-agent header.
|
228 |
if (!isset($this->config['headers'])) {
|
229 |
+
$this->config['headers'] = ['User-Agent' => default_user_agent()];
|
230 |
} else {
|
231 |
// Add the User-Agent header if one was not already set.
|
232 |
foreach (\array_keys($this->config['headers']) as $name) {
|
234 |
return;
|
235 |
}
|
236 |
}
|
237 |
+
$this->config['headers']['User-Agent'] = default_user_agent();
|
238 |
}
|
239 |
}
|
|
|
240 |
/**
|
241 |
* Merges default options into the array.
|
242 |
*
|
243 |
* @param array $options Options to modify by reference
|
244 |
+
*
|
245 |
+
* @return array
|
246 |
*/
|
247 |
+
private function prepareDefaults(array $options)
|
248 |
{
|
249 |
$defaults = $this->config;
|
|
|
250 |
if (!empty($defaults['headers'])) {
|
251 |
// Default headers are only added if they are not present.
|
252 |
$defaults['_conditional'] = $defaults['headers'];
|
253 |
unset($defaults['headers']);
|
254 |
}
|
|
|
255 |
// Special handling for headers is required as they are added as
|
256 |
// conditional headers and as headers passed to a request ctor.
|
257 |
if (\array_key_exists('headers', $options)) {
|
260 |
$defaults['_conditional'] = [];
|
261 |
unset($options['headers']);
|
262 |
} elseif (!\is_array($options['headers'])) {
|
263 |
+
throw new \InvalidArgumentException('headers must be an array');
|
264 |
}
|
265 |
}
|
|
|
266 |
// Shallow merge defaults underneath options.
|
267 |
$result = $options + $defaults;
|
|
|
268 |
// Remove null values.
|
269 |
foreach ($result as $k => $v) {
|
270 |
if ($v === null) {
|
271 |
unset($result[$k]);
|
272 |
}
|
273 |
}
|
|
|
274 |
return $result;
|
275 |
}
|
|
|
276 |
/**
|
277 |
* Transfers the given request and applies request options.
|
278 |
*
|
280 |
* as-is without merging in default options.
|
281 |
*
|
282 |
* @param array $options See \GuzzleHttp\RequestOptions.
|
283 |
+
*
|
284 |
+
* @return Promise\PromiseInterface
|
285 |
*/
|
286 |
+
private function transfer(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
287 |
{
|
288 |
+
// save_to -> sink
|
289 |
+
if (isset($options['save_to'])) {
|
290 |
+
$options['sink'] = $options['save_to'];
|
291 |
+
unset($options['save_to']);
|
292 |
+
}
|
293 |
+
// exceptions -> http_errors
|
294 |
+
if (isset($options['exceptions'])) {
|
295 |
+
$options['http_errors'] = $options['exceptions'];
|
296 |
+
unset($options['exceptions']);
|
297 |
+
}
|
298 |
$request = $this->applyOptions($request, $options);
|
299 |
/** @var HandlerStack $handler */
|
300 |
$handler = $options['handler'];
|
|
|
301 |
try {
|
302 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\promise_for($handler($request, $options));
|
303 |
} catch (\Exception $e) {
|
304 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($e);
|
305 |
}
|
306 |
}
|
|
|
307 |
/**
|
308 |
* Applies the array of request options to a request.
|
309 |
+
*
|
310 |
+
* @param RequestInterface $request
|
311 |
+
* @param array $options
|
312 |
+
*
|
313 |
+
* @return RequestInterface
|
314 |
*/
|
315 |
+
private function applyOptions(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array &$options)
|
316 |
{
|
317 |
+
$modify = ['set_headers' => []];
|
|
|
|
|
|
|
318 |
if (isset($options['headers'])) {
|
319 |
$modify['set_headers'] = $options['headers'];
|
320 |
unset($options['headers']);
|
321 |
}
|
|
|
322 |
if (isset($options['form_params'])) {
|
323 |
if (isset($options['multipart'])) {
|
324 |
+
throw new \InvalidArgumentException('You cannot use ' . 'form_params and multipart at the same time. Use the ' . 'form_params option if you want to send application/' . 'x-www-form-urlencoded requests, and the multipart ' . 'option to send multipart/form-data requests.');
|
|
|
|
|
|
|
|
|
325 |
}
|
326 |
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
327 |
unset($options['form_params']);
|
328 |
// Ensure that we don't have the header in different case and set the new value.
|
329 |
+
$options['_conditional'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
330 |
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
331 |
}
|
|
|
332 |
if (isset($options['multipart'])) {
|
333 |
+
$options['body'] = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\MultipartStream($options['multipart']);
|
334 |
unset($options['multipart']);
|
335 |
}
|
|
|
336 |
if (isset($options['json'])) {
|
337 |
+
$options['body'] = \PixelCaffeine\Dependencies\GuzzleHttp\json_encode($options['json']);
|
338 |
unset($options['json']);
|
339 |
// Ensure that we don't have the header in different case and set the new value.
|
340 |
+
$options['_conditional'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
341 |
$options['_conditional']['Content-Type'] = 'application/json';
|
342 |
}
|
343 |
+
if (!empty($options['decode_content']) && $options['decode_content'] !== \true) {
|
|
|
|
|
|
|
344 |
// Ensure that we don't have the header in different case and set the new value.
|
345 |
+
$options['_conditional'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
|
346 |
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
347 |
}
|
|
|
348 |
if (isset($options['body'])) {
|
349 |
if (\is_array($options['body'])) {
|
350 |
+
$this->invalidBody();
|
351 |
}
|
352 |
+
$modify['body'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($options['body']);
|
353 |
unset($options['body']);
|
354 |
}
|
|
|
355 |
if (!empty($options['auth']) && \is_array($options['auth'])) {
|
356 |
$value = $options['auth'];
|
357 |
$type = isset($value[2]) ? \strtolower($value[2]) : 'basic';
|
358 |
switch ($type) {
|
359 |
case 'basic':
|
360 |
// Ensure that we don't have the header in different case and set the new value.
|
361 |
+
$modify['set_headers'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
|
362 |
+
$modify['set_headers']['Authorization'] = 'Basic ' . \base64_encode("{$value[0]}:{$value[1]}");
|
|
|
363 |
break;
|
364 |
case 'digest':
|
365 |
// @todo: Do not rely on curl
|
366 |
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST;
|
367 |
+
$options['curl'][\CURLOPT_USERPWD] = "{$value[0]}:{$value[1]}";
|
368 |
break;
|
369 |
case 'ntlm':
|
370 |
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM;
|
371 |
+
$options['curl'][\CURLOPT_USERPWD] = "{$value[0]}:{$value[1]}";
|
372 |
break;
|
373 |
}
|
374 |
}
|
|
|
375 |
if (isset($options['query'])) {
|
376 |
$value = $options['query'];
|
377 |
if (\is_array($value)) {
|
378 |
+
$value = \http_build_query($value, null, '&', \PHP_QUERY_RFC3986);
|
379 |
}
|
380 |
if (!\is_string($value)) {
|
381 |
+
throw new \InvalidArgumentException('query must be a string or array');
|
382 |
}
|
383 |
$modify['query'] = $value;
|
384 |
unset($options['query']);
|
385 |
}
|
|
|
386 |
// Ensure that sink is not an invalid value.
|
387 |
if (isset($options['sink'])) {
|
388 |
// TODO: Add more sink validation?
|
389 |
if (\is_bool($options['sink'])) {
|
390 |
+
throw new \InvalidArgumentException('sink must not be a boolean');
|
391 |
}
|
392 |
}
|
393 |
+
$request = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\modify_request($request, $modify);
|
394 |
+
if ($request->getBody() instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\MultipartStream) {
|
|
|
395 |
// Use a multipart/form-data POST if a Content-Type is not set.
|
396 |
// Ensure that we don't have the header in different case and set the new value.
|
397 |
+
$options['_conditional'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
398 |
+
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' . $request->getBody()->getBoundary();
|
|
|
399 |
}
|
|
|
400 |
// Merge in conditional headers if they are not present.
|
401 |
if (isset($options['_conditional'])) {
|
402 |
// Build up the changes so it's in a single clone of the message.
|
406 |
$modify['set_headers'][$k] = $v;
|
407 |
}
|
408 |
}
|
409 |
+
$request = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\modify_request($request, $modify);
|
410 |
// Don't pass this internal value along to middleware/handlers.
|
411 |
unset($options['_conditional']);
|
412 |
}
|
|
|
413 |
return $request;
|
414 |
}
|
|
|
415 |
/**
|
416 |
+
* Throw Exception with pre-set message.
|
417 |
+
* @return void
|
418 |
+
* @throws \InvalidArgumentException Invalid body.
|
419 |
*/
|
420 |
+
private function invalidBody()
|
421 |
{
|
422 |
+
throw new \InvalidArgumentException('Passing in the "body" request ' . 'option as an array to send a POST request has been deprecated. ' . 'Please use the "form_params" request option to send a ' . 'application/x-www-form-urlencoded request, or the "multipart" ' . 'request option to send a multipart/form-data request.');
|
|
|
|
|
|
|
|
|
423 |
}
|
424 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/ClientInterface.php
RENAMED
@@ -1,23 +1,21 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use GuzzleHttp\Exception\GuzzleException;
|
6 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
7 |
-
use Psr\Http\Message\RequestInterface;
|
8 |
-
use Psr\Http\Message\ResponseInterface;
|
9 |
-
use Psr\Http\Message\UriInterface;
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Client interface for sending HTTP requests.
|
13 |
*/
|
14 |
interface ClientInterface
|
15 |
{
|
16 |
/**
|
17 |
-
*
|
18 |
*/
|
19 |
-
const
|
20 |
-
|
21 |
/**
|
22 |
* Send an HTTP request.
|
23 |
*
|
@@ -25,19 +23,20 @@ interface ClientInterface
|
|
25 |
* @param array $options Request options to apply to the given
|
26 |
* request and to the transfer.
|
27 |
*
|
|
|
28 |
* @throws GuzzleException
|
29 |
*/
|
30 |
-
public function send(RequestInterface $request, array $options = [])
|
31 |
-
|
32 |
/**
|
33 |
* Asynchronously send an HTTP request.
|
34 |
*
|
35 |
* @param RequestInterface $request Request to send
|
36 |
* @param array $options Request options to apply to the given
|
37 |
* request and to the transfer.
|
|
|
|
|
38 |
*/
|
39 |
-
public function sendAsync(RequestInterface $request, array $options = [])
|
40 |
-
|
41 |
/**
|
42 |
* Create and send an HTTP request.
|
43 |
*
|
@@ -49,10 +48,10 @@ interface ClientInterface
|
|
49 |
* @param string|UriInterface $uri URI object or string.
|
50 |
* @param array $options Request options to apply.
|
51 |
*
|
|
|
52 |
* @throws GuzzleException
|
53 |
*/
|
54 |
-
public function request(
|
55 |
-
|
56 |
/**
|
57 |
* Create and send an asynchronous HTTP request.
|
58 |
*
|
@@ -64,9 +63,10 @@ interface ClientInterface
|
|
64 |
* @param string $method HTTP method
|
65 |
* @param string|UriInterface $uri URI object or string.
|
66 |
* @param array $options Request options to apply.
|
|
|
|
|
67 |
*/
|
68 |
-
public function requestAsync(
|
69 |
-
|
70 |
/**
|
71 |
* Get a client configuration option.
|
72 |
*
|
@@ -77,8 +77,6 @@ interface ClientInterface
|
|
77 |
* @param string|null $option The config option to retrieve.
|
78 |
*
|
79 |
* @return mixed
|
80 |
-
*
|
81 |
-
* @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
82 |
*/
|
83 |
-
public function getConfig(
|
84 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\GuzzleException;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
10 |
/**
|
11 |
* Client interface for sending HTTP requests.
|
12 |
*/
|
13 |
interface ClientInterface
|
14 |
{
|
15 |
/**
|
16 |
+
* @deprecated Will be removed in Guzzle 7.0.0
|
17 |
*/
|
18 |
+
const VERSION = '6.5.5';
|
|
|
19 |
/**
|
20 |
* Send an HTTP request.
|
21 |
*
|
23 |
* @param array $options Request options to apply to the given
|
24 |
* request and to the transfer.
|
25 |
*
|
26 |
+
* @return ResponseInterface
|
27 |
* @throws GuzzleException
|
28 |
*/
|
29 |
+
public function send(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options = []);
|
|
|
30 |
/**
|
31 |
* Asynchronously send an HTTP request.
|
32 |
*
|
33 |
* @param RequestInterface $request Request to send
|
34 |
* @param array $options Request options to apply to the given
|
35 |
* request and to the transfer.
|
36 |
+
*
|
37 |
+
* @return PromiseInterface
|
38 |
*/
|
39 |
+
public function sendAsync(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options = []);
|
|
|
40 |
/**
|
41 |
* Create and send an HTTP request.
|
42 |
*
|
48 |
* @param string|UriInterface $uri URI object or string.
|
49 |
* @param array $options Request options to apply.
|
50 |
*
|
51 |
+
* @return ResponseInterface
|
52 |
* @throws GuzzleException
|
53 |
*/
|
54 |
+
public function request($method, $uri, array $options = []);
|
|
|
55 |
/**
|
56 |
* Create and send an asynchronous HTTP request.
|
57 |
*
|
63 |
* @param string $method HTTP method
|
64 |
* @param string|UriInterface $uri URI object or string.
|
65 |
* @param array $options Request options to apply.
|
66 |
+
*
|
67 |
+
* @return PromiseInterface
|
68 |
*/
|
69 |
+
public function requestAsync($method, $uri, array $options = []);
|
|
|
70 |
/**
|
71 |
* Get a client configuration option.
|
72 |
*
|
77 |
* @param string|null $option The config option to retrieve.
|
78 |
*
|
79 |
* @return mixed
|
|
|
|
|
80 |
*/
|
81 |
+
public function getConfig($option = null);
|
82 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/CookieJar.php
RENAMED
@@ -1,240 +1,186 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Cookie;
|
4 |
-
|
5 |
-
use Psr\Http\Message\RequestInterface;
|
6 |
-
use Psr\Http\Message\ResponseInterface;
|
7 |
|
|
|
|
|
8 |
/**
|
9 |
* Cookie jar that stores cookies as an array
|
10 |
*/
|
11 |
-
class CookieJar implements CookieJarInterface
|
12 |
{
|
13 |
-
/**
|
14 |
-
* @var SetCookie[] Loaded cookie data
|
15 |
-
*/
|
16 |
private $cookies = [];
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var bool
|
20 |
-
*/
|
21 |
private $strictMode;
|
22 |
-
|
23 |
/**
|
24 |
-
* @param bool
|
25 |
* cookies are added to the cookie jar.
|
26 |
* @param array $cookieArray Array of SetCookie objects or a hash of
|
27 |
* arrays that can be used with the SetCookie
|
28 |
* constructor
|
29 |
*/
|
30 |
-
public function __construct(
|
31 |
{
|
32 |
$this->strictMode = $strictMode;
|
33 |
-
|
34 |
foreach ($cookieArray as $cookie) {
|
35 |
-
if (
|
36 |
-
$cookie = new SetCookie($cookie);
|
37 |
}
|
38 |
$this->setCookie($cookie);
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
/**
|
43 |
* Create a new Cookie jar from an associative array and domain.
|
44 |
*
|
45 |
* @param array $cookies Cookies to create the jar from
|
46 |
* @param string $domain Domain to set the cookies to
|
|
|
|
|
47 |
*/
|
48 |
-
public static function fromArray(array $cookies,
|
49 |
{
|
50 |
$cookieJar = new self();
|
51 |
foreach ($cookies as $name => $value) {
|
52 |
-
$cookieJar->setCookie(new SetCookie([
|
53 |
-
'Domain' => $domain,
|
54 |
-
'Name' => $name,
|
55 |
-
'Value' => $value,
|
56 |
-
'Discard' => true
|
57 |
-
]));
|
58 |
}
|
59 |
-
|
60 |
return $cookieJar;
|
61 |
}
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* Evaluate if this cookie should be persisted to storage
|
65 |
* that survives between requests.
|
66 |
*
|
67 |
-
* @param SetCookie $cookie
|
68 |
-
* @param bool
|
|
|
69 |
*/
|
70 |
-
public static function shouldPersist(SetCookie $cookie,
|
71 |
{
|
72 |
if ($cookie->getExpires() || $allowSessionCookies) {
|
73 |
if (!$cookie->getDiscard()) {
|
74 |
-
return true;
|
75 |
}
|
76 |
}
|
77 |
-
|
78 |
-
return false;
|
79 |
}
|
80 |
-
|
81 |
/**
|
82 |
* Finds and returns the cookie based on the name
|
83 |
*
|
84 |
* @param string $name cookie name to search for
|
85 |
-
*
|
86 |
* @return SetCookie|null cookie that was found or null if not found
|
87 |
*/
|
88 |
-
public function getCookieByName(
|
89 |
{
|
|
|
|
|
|
|
|
|
90 |
foreach ($this->cookies as $cookie) {
|
91 |
if ($cookie->getName() !== null && \strcasecmp($cookie->getName(), $name) === 0) {
|
92 |
return $cookie;
|
93 |
}
|
94 |
}
|
95 |
-
|
96 |
return null;
|
97 |
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @inheritDoc
|
101 |
-
*/
|
102 |
-
public function toArray(): array
|
103 |
{
|
104 |
-
return \array_map(
|
105 |
return $cookie->toArray();
|
106 |
}, $this->getIterator()->getArrayCopy());
|
107 |
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* @inheritDoc
|
111 |
-
*/
|
112 |
-
public function clear(?string $domain = null, ?string $path = null, ?string $name = null): void
|
113 |
{
|
114 |
if (!$domain) {
|
115 |
$this->cookies = [];
|
116 |
return;
|
117 |
} elseif (!$path) {
|
118 |
-
$this->cookies = \array_filter(
|
119 |
-
$
|
120 |
-
|
121 |
-
return !$cookie->matchesDomain($domain);
|
122 |
-
}
|
123 |
-
);
|
124 |
} elseif (!$name) {
|
125 |
-
$this->cookies = \array_filter(
|
126 |
-
$
|
127 |
-
|
128 |
-
return !($cookie->matchesPath($path) &&
|
129 |
-
$cookie->matchesDomain($domain));
|
130 |
-
}
|
131 |
-
);
|
132 |
} else {
|
133 |
-
$this->cookies = \array_filter(
|
134 |
-
$
|
135 |
-
|
136 |
-
return !($cookie->getName() == $name &&
|
137 |
-
$cookie->matchesPath($path) &&
|
138 |
-
$cookie->matchesDomain($domain));
|
139 |
-
}
|
140 |
-
);
|
141 |
}
|
142 |
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* @inheritDoc
|
146 |
-
*/
|
147 |
-
public function clearSessionCookies(): void
|
148 |
{
|
149 |
-
$this->cookies = \array_filter(
|
150 |
-
$
|
151 |
-
|
152 |
-
return !$cookie->getDiscard() && $cookie->getExpires();
|
153 |
-
}
|
154 |
-
);
|
155 |
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @inheritDoc
|
159 |
-
*/
|
160 |
-
public function setCookie(SetCookie $cookie): bool
|
161 |
{
|
162 |
// If the name string is empty (but not 0), ignore the set-cookie
|
163 |
// string entirely.
|
164 |
$name = $cookie->getName();
|
165 |
if (!$name && $name !== '0') {
|
166 |
-
return false;
|
167 |
}
|
168 |
-
|
169 |
// Only allow cookies with set and valid domain, name, value
|
170 |
$result = $cookie->validate();
|
171 |
-
if ($result !== true) {
|
172 |
if ($this->strictMode) {
|
173 |
throw new \RuntimeException('Invalid cookie: ' . $result);
|
|
|
|
|
|
|
174 |
}
|
175 |
-
$this->removeCookieIfEmpty($cookie);
|
176 |
-
return false;
|
177 |
}
|
178 |
-
|
179 |
// Resolve conflicts with previously set cookies
|
180 |
foreach ($this->cookies as $i => $c) {
|
181 |
-
|
182 |
// Two cookies are identical, when their path, and domain are
|
183 |
// identical.
|
184 |
-
if ($c->getPath() != $cookie->getPath() ||
|
185 |
-
$c->getDomain() != $cookie->getDomain() ||
|
186 |
-
$c->getName() != $cookie->getName()
|
187 |
-
) {
|
188 |
continue;
|
189 |
}
|
190 |
-
|
191 |
// The previously set cookie is a discard cookie and this one is
|
192 |
// not so allow the new cookie to be set
|
193 |
if (!$cookie->getDiscard() && $c->getDiscard()) {
|
194 |
unset($this->cookies[$i]);
|
195 |
continue;
|
196 |
}
|
197 |
-
|
198 |
// If the new cookie's expiration is further into the future, then
|
199 |
// replace the old cookie
|
200 |
if ($cookie->getExpires() > $c->getExpires()) {
|
201 |
unset($this->cookies[$i]);
|
202 |
continue;
|
203 |
}
|
204 |
-
|
205 |
// If the value has changed, we better change it
|
206 |
if ($cookie->getValue() !== $c->getValue()) {
|
207 |
unset($this->cookies[$i]);
|
208 |
continue;
|
209 |
}
|
210 |
-
|
211 |
// The cookie exists, so no need to continue
|
212 |
-
return false;
|
213 |
}
|
214 |
-
|
215 |
$this->cookies[] = $cookie;
|
216 |
-
|
217 |
-
return true;
|
218 |
}
|
219 |
-
|
220 |
-
public function count(): int
|
221 |
{
|
222 |
return \count($this->cookies);
|
223 |
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* @return \ArrayIterator<int, SetCookie>
|
227 |
-
*/
|
228 |
-
public function getIterator(): \ArrayIterator
|
229 |
{
|
230 |
return new \ArrayIterator(\array_values($this->cookies));
|
231 |
}
|
232 |
-
|
233 |
-
public function extractCookies(RequestInterface $request, ResponseInterface $response): void
|
234 |
{
|
235 |
if ($cookieHeader = $response->getHeader('Set-Cookie')) {
|
236 |
foreach ($cookieHeader as $cookie) {
|
237 |
-
$sc = SetCookie::fromString($cookie);
|
238 |
if (!$sc->getDomain()) {
|
239 |
$sc->setDomain($request->getUri()->getHost());
|
240 |
}
|
@@ -245,13 +191,15 @@ class CookieJar implements CookieJarInterface
|
|
245 |
}
|
246 |
}
|
247 |
}
|
248 |
-
|
249 |
/**
|
250 |
* Computes cookie path following RFC 6265 section 5.1.4
|
251 |
*
|
252 |
* @link https://tools.ietf.org/html/rfc6265#section-5.1.4
|
|
|
|
|
|
|
253 |
*/
|
254 |
-
private function getCookiePathFromRequest(RequestInterface $request)
|
255 |
{
|
256 |
$uriPath = $request->getUri()->getPath();
|
257 |
if ('' === $uriPath) {
|
@@ -263,51 +211,36 @@ class CookieJar implements CookieJarInterface
|
|
263 |
if ('/' === $uriPath) {
|
264 |
return '/';
|
265 |
}
|
266 |
-
$lastSlashPos = \strrpos($uriPath, '/')
|
267 |
-
if (0 === $lastSlashPos || false === $lastSlashPos) {
|
268 |
return '/';
|
269 |
}
|
270 |
-
|
271 |
return \substr($uriPath, 0, $lastSlashPos);
|
272 |
}
|
273 |
-
|
274 |
-
public function withCookieHeader(RequestInterface $request): RequestInterface
|
275 |
{
|
276 |
$values = [];
|
277 |
$uri = $request->getUri();
|
278 |
$scheme = $uri->getScheme();
|
279 |
$host = $uri->getHost();
|
280 |
$path = $uri->getPath() ?: '/';
|
281 |
-
|
282 |
foreach ($this->cookies as $cookie) {
|
283 |
-
if ($cookie->matchesPath($path) &&
|
284 |
-
$cookie->
|
285 |
-
!$cookie->isExpired() &&
|
286 |
-
(!$cookie->getSecure() || $scheme === 'https')
|
287 |
-
) {
|
288 |
-
$values[] = $cookie->getName() . '='
|
289 |
-
. $cookie->getValue();
|
290 |
}
|
291 |
}
|
292 |
-
|
293 |
-
return $values
|
294 |
-
? $request->withHeader('Cookie', \implode('; ', $values))
|
295 |
-
: $request;
|
296 |
}
|
297 |
-
|
298 |
/**
|
299 |
* If a cookie already exists and the server asks to set it again with a
|
300 |
* null value, the cookie must be deleted.
|
|
|
|
|
301 |
*/
|
302 |
-
private function removeCookieIfEmpty(SetCookie $cookie)
|
303 |
{
|
304 |
$cookieValue = $cookie->getValue();
|
305 |
if ($cookieValue === null || $cookieValue === '') {
|
306 |
-
$this->clear(
|
307 |
-
$cookie->getDomain(),
|
308 |
-
$cookie->getPath(),
|
309 |
-
$cookie->getName()
|
310 |
-
);
|
311 |
}
|
312 |
}
|
313 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Cookie;
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
7 |
/**
|
8 |
* Cookie jar that stores cookies as an array
|
9 |
*/
|
10 |
+
class CookieJar implements \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJarInterface
|
11 |
{
|
12 |
+
/** @var SetCookie[] Loaded cookie data */
|
|
|
|
|
13 |
private $cookies = [];
|
14 |
+
/** @var bool */
|
|
|
|
|
|
|
15 |
private $strictMode;
|
|
|
16 |
/**
|
17 |
+
* @param bool $strictMode Set to true to throw exceptions when invalid
|
18 |
* cookies are added to the cookie jar.
|
19 |
* @param array $cookieArray Array of SetCookie objects or a hash of
|
20 |
* arrays that can be used with the SetCookie
|
21 |
* constructor
|
22 |
*/
|
23 |
+
public function __construct($strictMode = \false, $cookieArray = [])
|
24 |
{
|
25 |
$this->strictMode = $strictMode;
|
|
|
26 |
foreach ($cookieArray as $cookie) {
|
27 |
+
if (!$cookie instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie) {
|
28 |
+
$cookie = new \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie($cookie);
|
29 |
}
|
30 |
$this->setCookie($cookie);
|
31 |
}
|
32 |
}
|
|
|
33 |
/**
|
34 |
* Create a new Cookie jar from an associative array and domain.
|
35 |
*
|
36 |
* @param array $cookies Cookies to create the jar from
|
37 |
* @param string $domain Domain to set the cookies to
|
38 |
+
*
|
39 |
+
* @return self
|
40 |
*/
|
41 |
+
public static function fromArray(array $cookies, $domain)
|
42 |
{
|
43 |
$cookieJar = new self();
|
44 |
foreach ($cookies as $name => $value) {
|
45 |
+
$cookieJar->setCookie(new \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie(['Domain' => $domain, 'Name' => $name, 'Value' => $value, 'Discard' => \true]));
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
|
|
47 |
return $cookieJar;
|
48 |
}
|
49 |
+
/**
|
50 |
+
* @deprecated
|
51 |
+
*/
|
52 |
+
public static function getCookieValue($value)
|
53 |
+
{
|
54 |
+
return $value;
|
55 |
+
}
|
56 |
/**
|
57 |
* Evaluate if this cookie should be persisted to storage
|
58 |
* that survives between requests.
|
59 |
*
|
60 |
+
* @param SetCookie $cookie Being evaluated.
|
61 |
+
* @param bool $allowSessionCookies If we should persist session cookies
|
62 |
+
* @return bool
|
63 |
*/
|
64 |
+
public static function shouldPersist(\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie, $allowSessionCookies = \false)
|
65 |
{
|
66 |
if ($cookie->getExpires() || $allowSessionCookies) {
|
67 |
if (!$cookie->getDiscard()) {
|
68 |
+
return \true;
|
69 |
}
|
70 |
}
|
71 |
+
return \false;
|
|
|
72 |
}
|
|
|
73 |
/**
|
74 |
* Finds and returns the cookie based on the name
|
75 |
*
|
76 |
* @param string $name cookie name to search for
|
|
|
77 |
* @return SetCookie|null cookie that was found or null if not found
|
78 |
*/
|
79 |
+
public function getCookieByName($name)
|
80 |
{
|
81 |
+
// don't allow a non string name
|
82 |
+
if ($name === null || !\is_scalar($name)) {
|
83 |
+
return null;
|
84 |
+
}
|
85 |
foreach ($this->cookies as $cookie) {
|
86 |
if ($cookie->getName() !== null && \strcasecmp($cookie->getName(), $name) === 0) {
|
87 |
return $cookie;
|
88 |
}
|
89 |
}
|
|
|
90 |
return null;
|
91 |
}
|
92 |
+
public function toArray()
|
|
|
|
|
|
|
|
|
93 |
{
|
94 |
+
return \array_map(function (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie) {
|
95 |
return $cookie->toArray();
|
96 |
}, $this->getIterator()->getArrayCopy());
|
97 |
}
|
98 |
+
public function clear($domain = null, $path = null, $name = null)
|
|
|
|
|
|
|
|
|
99 |
{
|
100 |
if (!$domain) {
|
101 |
$this->cookies = [];
|
102 |
return;
|
103 |
} elseif (!$path) {
|
104 |
+
$this->cookies = \array_filter($this->cookies, function (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie) use($domain) {
|
105 |
+
return !$cookie->matchesDomain($domain);
|
106 |
+
});
|
|
|
|
|
|
|
107 |
} elseif (!$name) {
|
108 |
+
$this->cookies = \array_filter($this->cookies, function (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie) use($path, $domain) {
|
109 |
+
return !($cookie->matchesPath($path) && $cookie->matchesDomain($domain));
|
110 |
+
});
|
|
|
|
|
|
|
|
|
111 |
} else {
|
112 |
+
$this->cookies = \array_filter($this->cookies, function (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie) use($path, $domain, $name) {
|
113 |
+
return !($cookie->getName() == $name && $cookie->matchesPath($path) && $cookie->matchesDomain($domain));
|
114 |
+
});
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
+
public function clearSessionCookies()
|
|
|
|
|
|
|
|
|
118 |
{
|
119 |
+
$this->cookies = \array_filter($this->cookies, function (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie) {
|
120 |
+
return !$cookie->getDiscard() && $cookie->getExpires();
|
121 |
+
});
|
|
|
|
|
|
|
122 |
}
|
123 |
+
public function setCookie(\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie)
|
|
|
|
|
|
|
|
|
124 |
{
|
125 |
// If the name string is empty (but not 0), ignore the set-cookie
|
126 |
// string entirely.
|
127 |
$name = $cookie->getName();
|
128 |
if (!$name && $name !== '0') {
|
129 |
+
return \false;
|
130 |
}
|
|
|
131 |
// Only allow cookies with set and valid domain, name, value
|
132 |
$result = $cookie->validate();
|
133 |
+
if ($result !== \true) {
|
134 |
if ($this->strictMode) {
|
135 |
throw new \RuntimeException('Invalid cookie: ' . $result);
|
136 |
+
} else {
|
137 |
+
$this->removeCookieIfEmpty($cookie);
|
138 |
+
return \false;
|
139 |
}
|
|
|
|
|
140 |
}
|
|
|
141 |
// Resolve conflicts with previously set cookies
|
142 |
foreach ($this->cookies as $i => $c) {
|
|
|
143 |
// Two cookies are identical, when their path, and domain are
|
144 |
// identical.
|
145 |
+
if ($c->getPath() != $cookie->getPath() || $c->getDomain() != $cookie->getDomain() || $c->getName() != $cookie->getName()) {
|
|
|
|
|
|
|
146 |
continue;
|
147 |
}
|
|
|
148 |
// The previously set cookie is a discard cookie and this one is
|
149 |
// not so allow the new cookie to be set
|
150 |
if (!$cookie->getDiscard() && $c->getDiscard()) {
|
151 |
unset($this->cookies[$i]);
|
152 |
continue;
|
153 |
}
|
|
|
154 |
// If the new cookie's expiration is further into the future, then
|
155 |
// replace the old cookie
|
156 |
if ($cookie->getExpires() > $c->getExpires()) {
|
157 |
unset($this->cookies[$i]);
|
158 |
continue;
|
159 |
}
|
|
|
160 |
// If the value has changed, we better change it
|
161 |
if ($cookie->getValue() !== $c->getValue()) {
|
162 |
unset($this->cookies[$i]);
|
163 |
continue;
|
164 |
}
|
|
|
165 |
// The cookie exists, so no need to continue
|
166 |
+
return \false;
|
167 |
}
|
|
|
168 |
$this->cookies[] = $cookie;
|
169 |
+
return \true;
|
|
|
170 |
}
|
171 |
+
public function count()
|
|
|
172 |
{
|
173 |
return \count($this->cookies);
|
174 |
}
|
175 |
+
public function getIterator()
|
|
|
|
|
|
|
|
|
176 |
{
|
177 |
return new \ArrayIterator(\array_values($this->cookies));
|
178 |
}
|
179 |
+
public function extractCookies(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response)
|
|
|
180 |
{
|
181 |
if ($cookieHeader = $response->getHeader('Set-Cookie')) {
|
182 |
foreach ($cookieHeader as $cookie) {
|
183 |
+
$sc = \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie::fromString($cookie);
|
184 |
if (!$sc->getDomain()) {
|
185 |
$sc->setDomain($request->getUri()->getHost());
|
186 |
}
|
191 |
}
|
192 |
}
|
193 |
}
|
|
|
194 |
/**
|
195 |
* Computes cookie path following RFC 6265 section 5.1.4
|
196 |
*
|
197 |
* @link https://tools.ietf.org/html/rfc6265#section-5.1.4
|
198 |
+
*
|
199 |
+
* @param RequestInterface $request
|
200 |
+
* @return string
|
201 |
*/
|
202 |
+
private function getCookiePathFromRequest(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request)
|
203 |
{
|
204 |
$uriPath = $request->getUri()->getPath();
|
205 |
if ('' === $uriPath) {
|
211 |
if ('/' === $uriPath) {
|
212 |
return '/';
|
213 |
}
|
214 |
+
if (0 === ($lastSlashPos = \strrpos($uriPath, '/'))) {
|
|
|
215 |
return '/';
|
216 |
}
|
|
|
217 |
return \substr($uriPath, 0, $lastSlashPos);
|
218 |
}
|
219 |
+
public function withCookieHeader(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request)
|
|
|
220 |
{
|
221 |
$values = [];
|
222 |
$uri = $request->getUri();
|
223 |
$scheme = $uri->getScheme();
|
224 |
$host = $uri->getHost();
|
225 |
$path = $uri->getPath() ?: '/';
|
|
|
226 |
foreach ($this->cookies as $cookie) {
|
227 |
+
if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme === 'https')) {
|
228 |
+
$values[] = $cookie->getName() . '=' . $cookie->getValue();
|
|
|
|
|
|
|
|
|
|
|
229 |
}
|
230 |
}
|
231 |
+
return $values ? $request->withHeader('Cookie', \implode('; ', $values)) : $request;
|
|
|
|
|
|
|
232 |
}
|
|
|
233 |
/**
|
234 |
* If a cookie already exists and the server asks to set it again with a
|
235 |
* null value, the cookie must be deleted.
|
236 |
+
*
|
237 |
+
* @param SetCookie $cookie
|
238 |
*/
|
239 |
+
private function removeCookieIfEmpty(\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie)
|
240 |
{
|
241 |
$cookieValue = $cookie->getValue();
|
242 |
if ($cookieValue === null || $cookieValue === '') {
|
243 |
+
$this->clear($cookie->getDomain(), $cookie->getPath(), $cookie->getName());
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
}
|
246 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php
RENAMED
@@ -1,10 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Cookie;
|
4 |
-
|
5 |
-
use Psr\Http\Message\RequestInterface;
|
6 |
-
use Psr\Http\Message\ResponseInterface;
|
7 |
|
|
|
|
|
8 |
/**
|
9 |
* Stores HTTP cookies.
|
10 |
*
|
@@ -13,8 +12,7 @@ use Psr\Http\Message\ResponseInterface;
|
|
13 |
* necessary. Subclasses are also responsible for storing and retrieving
|
14 |
* cookies from a file, database, etc.
|
15 |
*
|
16 |
-
* @link
|
17 |
-
* @extends \IteratorAggregate<SetCookie>
|
18 |
*/
|
19 |
interface CookieJarInterface extends \Countable, \IteratorAggregate
|
20 |
{
|
@@ -28,16 +26,14 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
|
28 |
*
|
29 |
* @return RequestInterface returns the modified request.
|
30 |
*/
|
31 |
-
public function withCookieHeader(RequestInterface $request)
|
32 |
-
|
33 |
/**
|
34 |
* Extract cookies from an HTTP response and store them in the CookieJar.
|
35 |
*
|
36 |
* @param RequestInterface $request Request that was sent
|
37 |
* @param ResponseInterface $response Response that was received
|
38 |
*/
|
39 |
-
public function extractCookies(RequestInterface $request, ResponseInterface $response)
|
40 |
-
|
41 |
/**
|
42 |
* Sets a cookie in the cookie jar.
|
43 |
*
|
@@ -45,8 +41,7 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
|
45 |
*
|
46 |
* @return bool Returns true on success or false on failure
|
47 |
*/
|
48 |
-
public function setCookie(SetCookie $cookie)
|
49 |
-
|
50 |
/**
|
51 |
* Remove cookies currently held in the cookie jar.
|
52 |
*
|
@@ -60,9 +55,10 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
|
60 |
* @param string|null $domain Clears cookies matching a domain
|
61 |
* @param string|null $path Clears cookies matching a domain and path
|
62 |
* @param string|null $name Clears cookies matching a domain, path, and name
|
|
|
|
|
63 |
*/
|
64 |
-
public function clear(
|
65 |
-
|
66 |
/**
|
67 |
* Discard all sessions cookies.
|
68 |
*
|
@@ -70,10 +66,11 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
|
70 |
* field set to true. To be called when the user agent shuts down according
|
71 |
* to RFC 2965.
|
72 |
*/
|
73 |
-
public function clearSessionCookies()
|
74 |
-
|
75 |
/**
|
76 |
* Converts the cookie jar to an array.
|
|
|
|
|
77 |
*/
|
78 |
-
public function toArray()
|
79 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Cookie;
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
7 |
/**
|
8 |
* Stores HTTP cookies.
|
9 |
*
|
12 |
* necessary. Subclasses are also responsible for storing and retrieving
|
13 |
* cookies from a file, database, etc.
|
14 |
*
|
15 |
+
* @link http://docs.python.org/2/library/cookielib.html Inspiration
|
|
|
16 |
*/
|
17 |
interface CookieJarInterface extends \Countable, \IteratorAggregate
|
18 |
{
|
26 |
*
|
27 |
* @return RequestInterface returns the modified request.
|
28 |
*/
|
29 |
+
public function withCookieHeader(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request);
|
|
|
30 |
/**
|
31 |
* Extract cookies from an HTTP response and store them in the CookieJar.
|
32 |
*
|
33 |
* @param RequestInterface $request Request that was sent
|
34 |
* @param ResponseInterface $response Response that was received
|
35 |
*/
|
36 |
+
public function extractCookies(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response);
|
|
|
37 |
/**
|
38 |
* Sets a cookie in the cookie jar.
|
39 |
*
|
41 |
*
|
42 |
* @return bool Returns true on success or false on failure
|
43 |
*/
|
44 |
+
public function setCookie(\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie $cookie);
|
|
|
45 |
/**
|
46 |
* Remove cookies currently held in the cookie jar.
|
47 |
*
|
55 |
* @param string|null $domain Clears cookies matching a domain
|
56 |
* @param string|null $path Clears cookies matching a domain and path
|
57 |
* @param string|null $name Clears cookies matching a domain, path, and name
|
58 |
+
*
|
59 |
+
* @return CookieJarInterface
|
60 |
*/
|
61 |
+
public function clear($domain = null, $path = null, $name = null);
|
|
|
62 |
/**
|
63 |
* Discard all sessions cookies.
|
64 |
*
|
66 |
* field set to true. To be called when the user agent shuts down according
|
67 |
* to RFC 2965.
|
68 |
*/
|
69 |
+
public function clearSessionCookies();
|
|
|
70 |
/**
|
71 |
* Converts the cookie jar to an array.
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
*/
|
75 |
+
public function toArray();
|
76 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php
RENAMED
@@ -1,44 +1,34 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Cookie;
|
4 |
-
|
5 |
-
use GuzzleHttp\Utils;
|
6 |
|
7 |
/**
|
8 |
* Persists non-session cookies using a JSON formatted file
|
9 |
*/
|
10 |
-
class FileCookieJar extends CookieJar
|
11 |
{
|
12 |
-
/**
|
13 |
-
* @var string filename
|
14 |
-
*/
|
15 |
private $filename;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var bool Control whether to persist session cookies or not.
|
19 |
-
*/
|
20 |
private $storeSessionCookies;
|
21 |
-
|
22 |
/**
|
23 |
* Create a new FileCookieJar object
|
24 |
*
|
25 |
-
* @param string $cookieFile
|
26 |
-
* @param bool
|
27 |
-
*
|
28 |
*
|
29 |
* @throws \RuntimeException if the file cannot be found or created
|
30 |
*/
|
31 |
-
public function __construct(
|
32 |
{
|
33 |
parent::__construct();
|
34 |
$this->filename = $cookieFile;
|
35 |
$this->storeSessionCookies = $storeSessionCookies;
|
36 |
-
|
37 |
if (\file_exists($cookieFile)) {
|
38 |
$this->load($cookieFile);
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
/**
|
43 |
* Saves the file when shutting down
|
44 |
*/
|
@@ -46,55 +36,48 @@ class FileCookieJar extends CookieJar
|
|
46 |
{
|
47 |
$this->save($this->filename);
|
48 |
}
|
49 |
-
|
50 |
/**
|
51 |
* Saves the cookies to a file.
|
52 |
*
|
53 |
* @param string $filename File to save
|
54 |
-
*
|
55 |
* @throws \RuntimeException if the file cannot be found or created
|
56 |
*/
|
57 |
-
public function save(
|
58 |
{
|
59 |
$json = [];
|
60 |
-
/** @var SetCookie $cookie */
|
61 |
foreach ($this as $cookie) {
|
62 |
-
|
|
|
63 |
$json[] = $cookie->toArray();
|
64 |
}
|
65 |
}
|
66 |
-
|
67 |
-
|
68 |
-
if (false === \file_put_contents($filename, $jsonStr, \LOCK_EX)) {
|
69 |
throw new \RuntimeException("Unable to save file {$filename}");
|
70 |
}
|
71 |
}
|
72 |
-
|
73 |
/**
|
74 |
* Load cookies from a JSON formatted file.
|
75 |
*
|
76 |
* Old cookies are kept unless overwritten by newly loaded ones.
|
77 |
*
|
78 |
* @param string $filename Cookie file to load.
|
79 |
-
*
|
80 |
* @throws \RuntimeException if the file cannot be loaded.
|
81 |
*/
|
82 |
-
public function load(
|
83 |
{
|
84 |
$json = \file_get_contents($filename);
|
85 |
-
if (false === $json) {
|
86 |
throw new \RuntimeException("Unable to load file {$filename}");
|
87 |
-
}
|
88 |
-
if ($json === '') {
|
89 |
return;
|
90 |
}
|
91 |
-
|
92 |
-
$data = Utils::jsonDecode($json, true);
|
93 |
if (\is_array($data)) {
|
94 |
-
foreach ($
|
95 |
-
$this->setCookie(new SetCookie($cookie));
|
96 |
}
|
97 |
-
} elseif (\
|
98 |
throw new \RuntimeException("Invalid cookie file: {$filename}");
|
99 |
}
|
100 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Cookie;
|
|
|
|
|
4 |
|
5 |
/**
|
6 |
* Persists non-session cookies using a JSON formatted file
|
7 |
*/
|
8 |
+
class FileCookieJar extends \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar
|
9 |
{
|
10 |
+
/** @var string filename */
|
|
|
|
|
11 |
private $filename;
|
12 |
+
/** @var bool Control whether to persist session cookies or not. */
|
|
|
|
|
|
|
13 |
private $storeSessionCookies;
|
|
|
14 |
/**
|
15 |
* Create a new FileCookieJar object
|
16 |
*
|
17 |
+
* @param string $cookieFile File to store the cookie data
|
18 |
+
* @param bool $storeSessionCookies Set to true to store session cookies
|
19 |
+
* in the cookie jar.
|
20 |
*
|
21 |
* @throws \RuntimeException if the file cannot be found or created
|
22 |
*/
|
23 |
+
public function __construct($cookieFile, $storeSessionCookies = \false)
|
24 |
{
|
25 |
parent::__construct();
|
26 |
$this->filename = $cookieFile;
|
27 |
$this->storeSessionCookies = $storeSessionCookies;
|
|
|
28 |
if (\file_exists($cookieFile)) {
|
29 |
$this->load($cookieFile);
|
30 |
}
|
31 |
}
|
|
|
32 |
/**
|
33 |
* Saves the file when shutting down
|
34 |
*/
|
36 |
{
|
37 |
$this->save($this->filename);
|
38 |
}
|
|
|
39 |
/**
|
40 |
* Saves the cookies to a file.
|
41 |
*
|
42 |
* @param string $filename File to save
|
|
|
43 |
* @throws \RuntimeException if the file cannot be found or created
|
44 |
*/
|
45 |
+
public function save($filename)
|
46 |
{
|
47 |
$json = [];
|
|
|
48 |
foreach ($this as $cookie) {
|
49 |
+
/** @var SetCookie $cookie */
|
50 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
|
51 |
$json[] = $cookie->toArray();
|
52 |
}
|
53 |
}
|
54 |
+
$jsonStr = \PixelCaffeine\Dependencies\GuzzleHttp\json_encode($json);
|
55 |
+
if (\false === \file_put_contents($filename, $jsonStr, \LOCK_EX)) {
|
|
|
56 |
throw new \RuntimeException("Unable to save file {$filename}");
|
57 |
}
|
58 |
}
|
|
|
59 |
/**
|
60 |
* Load cookies from a JSON formatted file.
|
61 |
*
|
62 |
* Old cookies are kept unless overwritten by newly loaded ones.
|
63 |
*
|
64 |
* @param string $filename Cookie file to load.
|
|
|
65 |
* @throws \RuntimeException if the file cannot be loaded.
|
66 |
*/
|
67 |
+
public function load($filename)
|
68 |
{
|
69 |
$json = \file_get_contents($filename);
|
70 |
+
if (\false === $json) {
|
71 |
throw new \RuntimeException("Unable to load file {$filename}");
|
72 |
+
} elseif ($json === '') {
|
|
|
73 |
return;
|
74 |
}
|
75 |
+
$data = \PixelCaffeine\Dependencies\GuzzleHttp\json_decode($json, \true);
|
|
|
76 |
if (\is_array($data)) {
|
77 |
+
foreach (\json_decode($json, \true) as $cookie) {
|
78 |
+
$this->setCookie(new \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie($cookie));
|
79 |
}
|
80 |
+
} elseif (\strlen($data)) {
|
81 |
throw new \RuntimeException("Invalid cookie file: {$filename}");
|
82 |
}
|
83 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php
RENAMED
@@ -1,38 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Cookie;
|
4 |
|
5 |
/**
|
6 |
* Persists cookies in the client session
|
7 |
*/
|
8 |
-
class SessionCookieJar extends CookieJar
|
9 |
{
|
10 |
-
/**
|
11 |
-
* @var string session key
|
12 |
-
*/
|
13 |
private $sessionKey;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @var bool Control whether to persist session cookies or not.
|
17 |
-
*/
|
18 |
private $storeSessionCookies;
|
19 |
-
|
20 |
/**
|
21 |
* Create a new SessionCookieJar object
|
22 |
*
|
23 |
-
* @param string $sessionKey
|
24 |
-
*
|
25 |
-
* @param bool
|
26 |
-
*
|
27 |
*/
|
28 |
-
public function __construct(
|
29 |
{
|
30 |
parent::__construct();
|
31 |
$this->sessionKey = $sessionKey;
|
32 |
$this->storeSessionCookies = $storeSessionCookies;
|
33 |
$this->load();
|
34 |
}
|
35 |
-
|
36 |
/**
|
37 |
* Saves cookies to session when shutting down
|
38 |
*/
|
@@ -40,35 +33,32 @@ class SessionCookieJar extends CookieJar
|
|
40 |
{
|
41 |
$this->save();
|
42 |
}
|
43 |
-
|
44 |
/**
|
45 |
* Save cookies to the client session
|
46 |
*/
|
47 |
-
public function save()
|
48 |
{
|
49 |
$json = [];
|
50 |
-
/** @var SetCookie $cookie */
|
51 |
foreach ($this as $cookie) {
|
52 |
-
|
|
|
53 |
$json[] = $cookie->toArray();
|
54 |
}
|
55 |
}
|
56 |
-
|
57 |
$_SESSION[$this->sessionKey] = \json_encode($json);
|
58 |
}
|
59 |
-
|
60 |
/**
|
61 |
* Load the contents of the client session into the data array
|
62 |
*/
|
63 |
-
protected function load()
|
64 |
{
|
65 |
if (!isset($_SESSION[$this->sessionKey])) {
|
66 |
return;
|
67 |
}
|
68 |
-
$data = \json_decode($_SESSION[$this->sessionKey], true);
|
69 |
if (\is_array($data)) {
|
70 |
foreach ($data as $cookie) {
|
71 |
-
$this->setCookie(new SetCookie($cookie));
|
72 |
}
|
73 |
} elseif (\strlen($data)) {
|
74 |
throw new \RuntimeException("Invalid cookie data");
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Cookie;
|
4 |
|
5 |
/**
|
6 |
* Persists cookies in the client session
|
7 |
*/
|
8 |
+
class SessionCookieJar extends \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar
|
9 |
{
|
10 |
+
/** @var string session key */
|
|
|
|
|
11 |
private $sessionKey;
|
12 |
+
/** @var bool Control whether to persist session cookies or not. */
|
|
|
|
|
|
|
13 |
private $storeSessionCookies;
|
|
|
14 |
/**
|
15 |
* Create a new SessionCookieJar object
|
16 |
*
|
17 |
+
* @param string $sessionKey Session key name to store the cookie
|
18 |
+
* data in session
|
19 |
+
* @param bool $storeSessionCookies Set to true to store session cookies
|
20 |
+
* in the cookie jar.
|
21 |
*/
|
22 |
+
public function __construct($sessionKey, $storeSessionCookies = \false)
|
23 |
{
|
24 |
parent::__construct();
|
25 |
$this->sessionKey = $sessionKey;
|
26 |
$this->storeSessionCookies = $storeSessionCookies;
|
27 |
$this->load();
|
28 |
}
|
|
|
29 |
/**
|
30 |
* Saves cookies to session when shutting down
|
31 |
*/
|
33 |
{
|
34 |
$this->save();
|
35 |
}
|
|
|
36 |
/**
|
37 |
* Save cookies to the client session
|
38 |
*/
|
39 |
+
public function save()
|
40 |
{
|
41 |
$json = [];
|
|
|
42 |
foreach ($this as $cookie) {
|
43 |
+
/** @var SetCookie $cookie */
|
44 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
|
45 |
$json[] = $cookie->toArray();
|
46 |
}
|
47 |
}
|
|
|
48 |
$_SESSION[$this->sessionKey] = \json_encode($json);
|
49 |
}
|
|
|
50 |
/**
|
51 |
* Load the contents of the client session into the data array
|
52 |
*/
|
53 |
+
protected function load()
|
54 |
{
|
55 |
if (!isset($_SESSION[$this->sessionKey])) {
|
56 |
return;
|
57 |
}
|
58 |
+
$data = \json_decode($_SESSION[$this->sessionKey], \true);
|
59 |
if (\is_array($data)) {
|
60 |
foreach ($data as $cookie) {
|
61 |
+
$this->setCookie(new \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\SetCookie($cookie));
|
62 |
}
|
63 |
} elseif (\strlen($data)) {
|
64 |
throw new \RuntimeException("Invalid cookie data");
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Cookie/SetCookie.php
RENAMED
@@ -1,58 +1,40 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Cookie;
|
4 |
|
5 |
/**
|
6 |
* Set-Cookie object
|
7 |
*/
|
8 |
class SetCookie
|
9 |
{
|
10 |
-
/**
|
11 |
-
|
12 |
-
|
13 |
-
private static $defaults = [
|
14 |
-
'Name' => null,
|
15 |
-
'Value' => null,
|
16 |
-
'Domain' => null,
|
17 |
-
'Path' => '/',
|
18 |
-
'Max-Age' => null,
|
19 |
-
'Expires' => null,
|
20 |
-
'Secure' => false,
|
21 |
-
'Discard' => false,
|
22 |
-
'HttpOnly' => false
|
23 |
-
];
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var array Cookie data
|
27 |
-
*/
|
28 |
private $data;
|
29 |
-
|
30 |
/**
|
31 |
-
* Create a new SetCookie object from a string
|
32 |
*
|
33 |
* @param string $cookie Set-Cookie header string
|
|
|
|
|
34 |
*/
|
35 |
-
public static function fromString(
|
36 |
{
|
37 |
// Create the default return array
|
38 |
$data = self::$defaults;
|
39 |
// Explode the cookie string using a series of semicolons
|
40 |
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
|
41 |
// The name of the cookie (first kvp) must exist and include an equal sign.
|
42 |
-
if (
|
43 |
return new self($data);
|
44 |
}
|
45 |
-
|
46 |
// Add the cookie pieces into the parsed data array
|
47 |
foreach ($pieces as $part) {
|
48 |
$cookieParts = \explode('=', $part, 2);
|
49 |
$key = \trim($cookieParts[0]);
|
50 |
-
$value = isset($cookieParts[1])
|
51 |
-
? \trim($cookieParts[1], " \n\r\t\0\x0B")
|
52 |
-
: true;
|
53 |
-
|
54 |
// Only check for non-cookies when cookies have been found
|
55 |
-
if (
|
56 |
$data['Name'] = $key;
|
57 |
$data['Value'] = $value;
|
58 |
} else {
|
@@ -65,54 +47,42 @@ class SetCookie
|
|
65 |
$data[$key] = $value;
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
return new self($data);
|
70 |
}
|
71 |
-
|
72 |
/**
|
73 |
* @param array $data Array of cookie data provided by a Cookie parser
|
74 |
*/
|
75 |
public function __construct(array $data = [])
|
76 |
{
|
77 |
-
|
78 |
-
$replaced = \array_replace(self::$defaults, $data);
|
79 |
-
if ($replaced === null) {
|
80 |
-
throw new \InvalidArgumentException('Unable to replace the default values for the Cookie.');
|
81 |
-
}
|
82 |
-
|
83 |
-
$this->data = $replaced;
|
84 |
// Extract the Expires value and turn it into a UNIX timestamp if needed
|
85 |
if (!$this->getExpires() && $this->getMaxAge()) {
|
86 |
// Calculate the Expires date
|
87 |
$this->setExpires(\time() + $this->getMaxAge());
|
88 |
-
} elseif (
|
89 |
-
$this->setExpires($
|
90 |
}
|
91 |
}
|
92 |
-
|
93 |
public function __toString()
|
94 |
{
|
95 |
$str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
|
96 |
foreach ($this->data as $k => $v) {
|
97 |
-
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
|
98 |
if ($k === 'Expires') {
|
99 |
-
$str .= 'Expires=' . \gmdate('D, d M Y H:i:s
|
100 |
} else {
|
101 |
-
$str .= ($v === true ? $k : "{$k}={$v}") . '; ';
|
102 |
}
|
103 |
}
|
104 |
}
|
105 |
-
|
106 |
return \rtrim($str, '; ');
|
107 |
}
|
108 |
-
|
109 |
-
public function toArray(): array
|
110 |
{
|
111 |
return $this->data;
|
112 |
}
|
113 |
-
|
114 |
/**
|
115 |
-
* Get the cookie name
|
116 |
*
|
117 |
* @return string
|
118 |
*/
|
@@ -120,39 +90,35 @@ class SetCookie
|
|
120 |
{
|
121 |
return $this->data['Name'];
|
122 |
}
|
123 |
-
|
124 |
/**
|
125 |
-
* Set the cookie name
|
126 |
*
|
127 |
* @param string $name Cookie name
|
128 |
*/
|
129 |
-
public function setName($name)
|
130 |
{
|
131 |
$this->data['Name'] = $name;
|
132 |
}
|
133 |
-
|
134 |
/**
|
135 |
-
* Get the cookie value
|
136 |
*
|
137 |
-
* @return string
|
138 |
*/
|
139 |
public function getValue()
|
140 |
{
|
141 |
return $this->data['Value'];
|
142 |
}
|
143 |
-
|
144 |
/**
|
145 |
-
* Set the cookie value
|
146 |
*
|
147 |
* @param string $value Cookie value
|
148 |
*/
|
149 |
-
public function setValue($value)
|
150 |
{
|
151 |
$this->data['Value'] = $value;
|
152 |
}
|
153 |
-
|
154 |
/**
|
155 |
-
* Get the domain
|
156 |
*
|
157 |
* @return string|null
|
158 |
*/
|
@@ -160,19 +126,17 @@ class SetCookie
|
|
160 |
{
|
161 |
return $this->data['Domain'];
|
162 |
}
|
163 |
-
|
164 |
/**
|
165 |
-
* Set the domain of the cookie
|
166 |
*
|
167 |
* @param string $domain
|
168 |
*/
|
169 |
-
public function setDomain($domain)
|
170 |
{
|
171 |
$this->data['Domain'] = $domain;
|
172 |
}
|
173 |
-
|
174 |
/**
|
175 |
-
* Get the path
|
176 |
*
|
177 |
* @return string
|
178 |
*/
|
@@ -180,19 +144,17 @@ class SetCookie
|
|
180 |
{
|
181 |
return $this->data['Path'];
|
182 |
}
|
183 |
-
|
184 |
/**
|
185 |
-
* Set the path of the cookie
|
186 |
*
|
187 |
* @param string $path Path of the cookie
|
188 |
*/
|
189 |
-
public function setPath($path)
|
190 |
{
|
191 |
$this->data['Path'] = $path;
|
192 |
}
|
193 |
-
|
194 |
/**
|
195 |
-
* Maximum lifetime of the cookie in seconds
|
196 |
*
|
197 |
* @return int|null
|
198 |
*/
|
@@ -200,41 +162,35 @@ class SetCookie
|
|
200 |
{
|
201 |
return $this->data['Max-Age'];
|
202 |
}
|
203 |
-
|
204 |
/**
|
205 |
-
* Set the max-age of the cookie
|
206 |
*
|
207 |
* @param int $maxAge Max age of the cookie in seconds
|
208 |
*/
|
209 |
-
public function setMaxAge($maxAge)
|
210 |
{
|
211 |
$this->data['Max-Age'] = $maxAge;
|
212 |
}
|
213 |
-
|
214 |
/**
|
215 |
-
* The UNIX timestamp when the cookie Expires
|
216 |
*
|
217 |
-
* @return
|
218 |
*/
|
219 |
public function getExpires()
|
220 |
{
|
221 |
return $this->data['Expires'];
|
222 |
}
|
223 |
-
|
224 |
/**
|
225 |
-
* Set the unix timestamp for which the cookie will expire
|
226 |
*
|
227 |
-
* @param int
|
228 |
*/
|
229 |
-
public function setExpires($timestamp)
|
230 |
{
|
231 |
-
$this->data['Expires'] = \is_numeric($timestamp)
|
232 |
-
? (int) $timestamp
|
233 |
-
: \strtotime($timestamp);
|
234 |
}
|
235 |
-
|
236 |
/**
|
237 |
-
* Get whether or not this is a secure cookie
|
238 |
*
|
239 |
* @return bool|null
|
240 |
*/
|
@@ -242,19 +198,17 @@ class SetCookie
|
|
242 |
{
|
243 |
return $this->data['Secure'];
|
244 |
}
|
245 |
-
|
246 |
/**
|
247 |
-
* Set whether or not the cookie is secure
|
248 |
*
|
249 |
* @param bool $secure Set to true or false if secure
|
250 |
*/
|
251 |
-
public function setSecure($secure)
|
252 |
{
|
253 |
$this->data['Secure'] = $secure;
|
254 |
}
|
255 |
-
|
256 |
/**
|
257 |
-
* Get whether or not this is a session cookie
|
258 |
*
|
259 |
* @return bool|null
|
260 |
*/
|
@@ -262,19 +216,17 @@ class SetCookie
|
|
262 |
{
|
263 |
return $this->data['Discard'];
|
264 |
}
|
265 |
-
|
266 |
/**
|
267 |
-
* Set whether or not this is a session cookie
|
268 |
*
|
269 |
* @param bool $discard Set to true or false if this is a session cookie
|
270 |
*/
|
271 |
-
public function setDiscard($discard)
|
272 |
{
|
273 |
$this->data['Discard'] = $discard;
|
274 |
}
|
275 |
-
|
276 |
/**
|
277 |
-
* Get whether or not this is an HTTP only cookie
|
278 |
*
|
279 |
* @return bool
|
280 |
*/
|
@@ -282,17 +234,15 @@ class SetCookie
|
|
282 |
{
|
283 |
return $this->data['HttpOnly'];
|
284 |
}
|
285 |
-
|
286 |
/**
|
287 |
-
* Set whether or not this is an HTTP only cookie
|
288 |
*
|
289 |
* @param bool $httpOnly Set to true or false if this is HTTP only
|
290 |
*/
|
291 |
-
public function setHttpOnly($httpOnly)
|
292 |
{
|
293 |
$this->data['HttpOnly'] = $httpOnly;
|
294 |
}
|
295 |
-
|
296 |
/**
|
297 |
* Check if the cookie matches a path value.
|
298 |
*
|
@@ -307,104 +257,87 @@ class SetCookie
|
|
307 |
* path is a %x2F ("/") character.
|
308 |
*
|
309 |
* @param string $requestPath Path to check against
|
|
|
|
|
310 |
*/
|
311 |
-
public function matchesPath(
|
312 |
{
|
313 |
$cookiePath = $this->getPath();
|
314 |
-
|
315 |
// Match on exact matches or when path is the default empty "/"
|
316 |
if ($cookiePath === '/' || $cookiePath == $requestPath) {
|
317 |
-
return true;
|
318 |
}
|
319 |
-
|
320 |
// Ensure that the cookie-path is a prefix of the request path.
|
321 |
if (0 !== \strpos($requestPath, $cookiePath)) {
|
322 |
-
return false;
|
323 |
}
|
324 |
-
|
325 |
// Match if the last character of the cookie-path is "/"
|
326 |
if (\substr($cookiePath, -1, 1) === '/') {
|
327 |
-
return true;
|
328 |
}
|
329 |
-
|
330 |
// Match if the first character not included in cookie path is "/"
|
331 |
return \substr($requestPath, \strlen($cookiePath), 1) === '/';
|
332 |
}
|
333 |
-
|
334 |
/**
|
335 |
-
* Check if the cookie matches a domain value
|
336 |
*
|
337 |
* @param string $domain Domain to check against
|
|
|
|
|
338 |
*/
|
339 |
-
public function matchesDomain(
|
340 |
{
|
341 |
-
$cookieDomain = $this->getDomain();
|
342 |
-
if (null === $cookieDomain) {
|
343 |
-
return true;
|
344 |
-
}
|
345 |
-
|
346 |
// Remove the leading '.' as per spec in RFC 6265.
|
347 |
-
//
|
348 |
-
$cookieDomain = \ltrim($
|
349 |
-
|
350 |
// Domain not set or exact match.
|
351 |
if (!$cookieDomain || !\strcasecmp($domain, $cookieDomain)) {
|
352 |
-
return true;
|
353 |
}
|
354 |
-
|
355 |
// Matching the subdomain according to RFC 6265.
|
356 |
-
//
|
357 |
if (\filter_var($domain, \FILTER_VALIDATE_IP)) {
|
358 |
-
return false;
|
359 |
}
|
360 |
-
|
361 |
-
return (bool) \preg_match('/\.' . \preg_quote($cookieDomain, '/') . '$/', $domain);
|
362 |
}
|
363 |
-
|
364 |
/**
|
365 |
-
* Check if the cookie is expired
|
|
|
|
|
366 |
*/
|
367 |
-
public function isExpired()
|
368 |
{
|
369 |
return $this->getExpires() !== null && \time() > $this->getExpires();
|
370 |
}
|
371 |
-
|
372 |
/**
|
373 |
-
* Check if the cookie is valid according to RFC 6265
|
374 |
*
|
375 |
* @return bool|string Returns true if valid or an error message if invalid
|
376 |
*/
|
377 |
public function validate()
|
378 |
{
|
|
|
379 |
$name = $this->getName();
|
380 |
-
if ($name
|
381 |
return 'The cookie name must not be empty';
|
382 |
}
|
383 |
-
|
384 |
// Check if any of the invalid characters are present in the cookie name
|
385 |
-
if (\preg_match(
|
386 |
-
'
|
387 |
-
$name
|
388 |
-
)) {
|
389 |
-
return 'Cookie name must not contain invalid characters: ASCII '
|
390 |
-
. 'Control characters (0-31;127), space, tab and the '
|
391 |
-
. 'following characters: ()<>@,;:\"/?={}';
|
392 |
}
|
393 |
-
|
394 |
-
// Value must not be null. 0 and empty string are valid. Empty strings
|
395 |
-
// are technically against RFC 6265, but known to happen in the wild.
|
396 |
$value = $this->getValue();
|
397 |
-
if ($value
|
398 |
return 'The cookie value must not be empty';
|
399 |
}
|
400 |
-
|
401 |
-
//
|
402 |
-
//
|
403 |
$domain = $this->getDomain();
|
404 |
-
if ($domain
|
405 |
return 'The cookie domain must not be empty';
|
406 |
}
|
407 |
-
|
408 |
-
return true;
|
409 |
}
|
410 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Cookie;
|
4 |
|
5 |
/**
|
6 |
* Set-Cookie object
|
7 |
*/
|
8 |
class SetCookie
|
9 |
{
|
10 |
+
/** @var array */
|
11 |
+
private static $defaults = ['Name' => null, 'Value' => null, 'Domain' => null, 'Path' => '/', 'Max-Age' => null, 'Expires' => null, 'Secure' => \false, 'Discard' => \false, 'HttpOnly' => \false];
|
12 |
+
/** @var array Cookie data */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
private $data;
|
|
|
14 |
/**
|
15 |
+
* Create a new SetCookie object from a string
|
16 |
*
|
17 |
* @param string $cookie Set-Cookie header string
|
18 |
+
*
|
19 |
+
* @return self
|
20 |
*/
|
21 |
+
public static function fromString($cookie)
|
22 |
{
|
23 |
// Create the default return array
|
24 |
$data = self::$defaults;
|
25 |
// Explode the cookie string using a series of semicolons
|
26 |
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
|
27 |
// The name of the cookie (first kvp) must exist and include an equal sign.
|
28 |
+
if (empty($pieces[0]) || !\strpos($pieces[0], '=')) {
|
29 |
return new self($data);
|
30 |
}
|
|
|
31 |
// Add the cookie pieces into the parsed data array
|
32 |
foreach ($pieces as $part) {
|
33 |
$cookieParts = \explode('=', $part, 2);
|
34 |
$key = \trim($cookieParts[0]);
|
35 |
+
$value = isset($cookieParts[1]) ? \trim($cookieParts[1], " \n\r\t\0\v") : \true;
|
|
|
|
|
|
|
36 |
// Only check for non-cookies when cookies have been found
|
37 |
+
if (empty($data['Name'])) {
|
38 |
$data['Name'] = $key;
|
39 |
$data['Value'] = $value;
|
40 |
} else {
|
47 |
$data[$key] = $value;
|
48 |
}
|
49 |
}
|
|
|
50 |
return new self($data);
|
51 |
}
|
|
|
52 |
/**
|
53 |
* @param array $data Array of cookie data provided by a Cookie parser
|
54 |
*/
|
55 |
public function __construct(array $data = [])
|
56 |
{
|
57 |
+
$this->data = \array_replace(self::$defaults, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
// Extract the Expires value and turn it into a UNIX timestamp if needed
|
59 |
if (!$this->getExpires() && $this->getMaxAge()) {
|
60 |
// Calculate the Expires date
|
61 |
$this->setExpires(\time() + $this->getMaxAge());
|
62 |
+
} elseif ($this->getExpires() && !\is_numeric($this->getExpires())) {
|
63 |
+
$this->setExpires($this->getExpires());
|
64 |
}
|
65 |
}
|
|
|
66 |
public function __toString()
|
67 |
{
|
68 |
$str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
|
69 |
foreach ($this->data as $k => $v) {
|
70 |
+
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== \false) {
|
71 |
if ($k === 'Expires') {
|
72 |
+
$str .= 'Expires=' . \gmdate('D, d M Y H:i:s \\G\\M\\T', $v) . '; ';
|
73 |
} else {
|
74 |
+
$str .= ($v === \true ? $k : "{$k}={$v}") . '; ';
|
75 |
}
|
76 |
}
|
77 |
}
|
|
|
78 |
return \rtrim($str, '; ');
|
79 |
}
|
80 |
+
public function toArray()
|
|
|
81 |
{
|
82 |
return $this->data;
|
83 |
}
|
|
|
84 |
/**
|
85 |
+
* Get the cookie name
|
86 |
*
|
87 |
* @return string
|
88 |
*/
|
90 |
{
|
91 |
return $this->data['Name'];
|
92 |
}
|
|
|
93 |
/**
|
94 |
+
* Set the cookie name
|
95 |
*
|
96 |
* @param string $name Cookie name
|
97 |
*/
|
98 |
+
public function setName($name)
|
99 |
{
|
100 |
$this->data['Name'] = $name;
|
101 |
}
|
|
|
102 |
/**
|
103 |
+
* Get the cookie value
|
104 |
*
|
105 |
+
* @return string
|
106 |
*/
|
107 |
public function getValue()
|
108 |
{
|
109 |
return $this->data['Value'];
|
110 |
}
|
|
|
111 |
/**
|
112 |
+
* Set the cookie value
|
113 |
*
|
114 |
* @param string $value Cookie value
|
115 |
*/
|
116 |
+
public function setValue($value)
|
117 |
{
|
118 |
$this->data['Value'] = $value;
|
119 |
}
|
|
|
120 |
/**
|
121 |
+
* Get the domain
|
122 |
*
|
123 |
* @return string|null
|
124 |
*/
|
126 |
{
|
127 |
return $this->data['Domain'];
|
128 |
}
|
|
|
129 |
/**
|
130 |
+
* Set the domain of the cookie
|
131 |
*
|
132 |
* @param string $domain
|
133 |
*/
|
134 |
+
public function setDomain($domain)
|
135 |
{
|
136 |
$this->data['Domain'] = $domain;
|
137 |
}
|
|
|
138 |
/**
|
139 |
+
* Get the path
|
140 |
*
|
141 |
* @return string
|
142 |
*/
|
144 |
{
|
145 |
return $this->data['Path'];
|
146 |
}
|
|
|
147 |
/**
|
148 |
+
* Set the path of the cookie
|
149 |
*
|
150 |
* @param string $path Path of the cookie
|
151 |
*/
|
152 |
+
public function setPath($path)
|
153 |
{
|
154 |
$this->data['Path'] = $path;
|
155 |
}
|
|
|
156 |
/**
|
157 |
+
* Maximum lifetime of the cookie in seconds
|
158 |
*
|
159 |
* @return int|null
|
160 |
*/
|
162 |
{
|
163 |
return $this->data['Max-Age'];
|
164 |
}
|
|
|
165 |
/**
|
166 |
+
* Set the max-age of the cookie
|
167 |
*
|
168 |
* @param int $maxAge Max age of the cookie in seconds
|
169 |
*/
|
170 |
+
public function setMaxAge($maxAge)
|
171 |
{
|
172 |
$this->data['Max-Age'] = $maxAge;
|
173 |
}
|
|
|
174 |
/**
|
175 |
+
* The UNIX timestamp when the cookie Expires
|
176 |
*
|
177 |
+
* @return mixed
|
178 |
*/
|
179 |
public function getExpires()
|
180 |
{
|
181 |
return $this->data['Expires'];
|
182 |
}
|
|
|
183 |
/**
|
184 |
+
* Set the unix timestamp for which the cookie will expire
|
185 |
*
|
186 |
+
* @param int $timestamp Unix timestamp
|
187 |
*/
|
188 |
+
public function setExpires($timestamp)
|
189 |
{
|
190 |
+
$this->data['Expires'] = \is_numeric($timestamp) ? (int) $timestamp : \strtotime($timestamp);
|
|
|
|
|
191 |
}
|
|
|
192 |
/**
|
193 |
+
* Get whether or not this is a secure cookie
|
194 |
*
|
195 |
* @return bool|null
|
196 |
*/
|
198 |
{
|
199 |
return $this->data['Secure'];
|
200 |
}
|
|
|
201 |
/**
|
202 |
+
* Set whether or not the cookie is secure
|
203 |
*
|
204 |
* @param bool $secure Set to true or false if secure
|
205 |
*/
|
206 |
+
public function setSecure($secure)
|
207 |
{
|
208 |
$this->data['Secure'] = $secure;
|
209 |
}
|
|
|
210 |
/**
|
211 |
+
* Get whether or not this is a session cookie
|
212 |
*
|
213 |
* @return bool|null
|
214 |
*/
|
216 |
{
|
217 |
return $this->data['Discard'];
|
218 |
}
|
|
|
219 |
/**
|
220 |
+
* Set whether or not this is a session cookie
|
221 |
*
|
222 |
* @param bool $discard Set to true or false if this is a session cookie
|
223 |
*/
|
224 |
+
public function setDiscard($discard)
|
225 |
{
|
226 |
$this->data['Discard'] = $discard;
|
227 |
}
|
|
|
228 |
/**
|
229 |
+
* Get whether or not this is an HTTP only cookie
|
230 |
*
|
231 |
* @return bool
|
232 |
*/
|
234 |
{
|
235 |
return $this->data['HttpOnly'];
|
236 |
}
|
|
|
237 |
/**
|
238 |
+
* Set whether or not this is an HTTP only cookie
|
239 |
*
|
240 |
* @param bool $httpOnly Set to true or false if this is HTTP only
|
241 |
*/
|
242 |
+
public function setHttpOnly($httpOnly)
|
243 |
{
|
244 |
$this->data['HttpOnly'] = $httpOnly;
|
245 |
}
|
|
|
246 |
/**
|
247 |
* Check if the cookie matches a path value.
|
248 |
*
|
257 |
* path is a %x2F ("/") character.
|
258 |
*
|
259 |
* @param string $requestPath Path to check against
|
260 |
+
*
|
261 |
+
* @return bool
|
262 |
*/
|
263 |
+
public function matchesPath($requestPath)
|
264 |
{
|
265 |
$cookiePath = $this->getPath();
|
|
|
266 |
// Match on exact matches or when path is the default empty "/"
|
267 |
if ($cookiePath === '/' || $cookiePath == $requestPath) {
|
268 |
+
return \true;
|
269 |
}
|
|
|
270 |
// Ensure that the cookie-path is a prefix of the request path.
|
271 |
if (0 !== \strpos($requestPath, $cookiePath)) {
|
272 |
+
return \false;
|
273 |
}
|
|
|
274 |
// Match if the last character of the cookie-path is "/"
|
275 |
if (\substr($cookiePath, -1, 1) === '/') {
|
276 |
+
return \true;
|
277 |
}
|
|
|
278 |
// Match if the first character not included in cookie path is "/"
|
279 |
return \substr($requestPath, \strlen($cookiePath), 1) === '/';
|
280 |
}
|
|
|
281 |
/**
|
282 |
+
* Check if the cookie matches a domain value
|
283 |
*
|
284 |
* @param string $domain Domain to check against
|
285 |
+
*
|
286 |
+
* @return bool
|
287 |
*/
|
288 |
+
public function matchesDomain($domain)
|
289 |
{
|
|
|
|
|
|
|
|
|
|
|
290 |
// Remove the leading '.' as per spec in RFC 6265.
|
291 |
+
// http://tools.ietf.org/html/rfc6265#section-5.2.3
|
292 |
+
$cookieDomain = \ltrim($this->getDomain(), '.');
|
|
|
293 |
// Domain not set or exact match.
|
294 |
if (!$cookieDomain || !\strcasecmp($domain, $cookieDomain)) {
|
295 |
+
return \true;
|
296 |
}
|
|
|
297 |
// Matching the subdomain according to RFC 6265.
|
298 |
+
// http://tools.ietf.org/html/rfc6265#section-5.1.3
|
299 |
if (\filter_var($domain, \FILTER_VALIDATE_IP)) {
|
300 |
+
return \false;
|
301 |
}
|
302 |
+
return (bool) \preg_match('/\\.' . \preg_quote($cookieDomain, '/') . '$/', $domain);
|
|
|
303 |
}
|
|
|
304 |
/**
|
305 |
+
* Check if the cookie is expired
|
306 |
+
*
|
307 |
+
* @return bool
|
308 |
*/
|
309 |
+
public function isExpired()
|
310 |
{
|
311 |
return $this->getExpires() !== null && \time() > $this->getExpires();
|
312 |
}
|
|
|
313 |
/**
|
314 |
+
* Check if the cookie is valid according to RFC 6265
|
315 |
*
|
316 |
* @return bool|string Returns true if valid or an error message if invalid
|
317 |
*/
|
318 |
public function validate()
|
319 |
{
|
320 |
+
// Names must not be empty, but can be 0
|
321 |
$name = $this->getName();
|
322 |
+
if (empty($name) && !\is_numeric($name)) {
|
323 |
return 'The cookie name must not be empty';
|
324 |
}
|
|
|
325 |
// Check if any of the invalid characters are present in the cookie name
|
326 |
+
if (\preg_match('/[\\x00-\\x20\\x22\\x28-\\x29\\x2c\\x2f\\x3a-\\x40\\x5c\\x7b\\x7d\\x7f]/', $name)) {
|
327 |
+
return 'Cookie name must not contain invalid characters: ASCII ' . 'Control characters (0-31;127), space, tab and the ' . 'following characters: ()<>@,;:\\"/?={}';
|
|
|
|
|
|
|
|
|
|
|
328 |
}
|
329 |
+
// Value must not be empty, but can be 0
|
|
|
|
|
330 |
$value = $this->getValue();
|
331 |
+
if (empty($value) && !\is_numeric($value)) {
|
332 |
return 'The cookie value must not be empty';
|
333 |
}
|
334 |
+
// Domains must not be empty, but can be 0
|
335 |
+
// A "0" is not a valid internet domain, but may be used as server name
|
336 |
+
// in a private network.
|
337 |
$domain = $this->getDomain();
|
338 |
+
if (empty($domain) && !\is_numeric($domain)) {
|
339 |
return 'The cookie domain must not be empty';
|
340 |
}
|
341 |
+
return \true;
|
|
|
342 |
}
|
343 |
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
7 |
+
/**
|
8 |
+
* Exception when an HTTP error occurs (4xx or 5xx error)
|
9 |
+
*/
|
10 |
+
class BadResponseException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException
|
11 |
+
{
|
12 |
+
public function __construct($message, \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, \Exception $previous = null, array $handlerContext = [])
|
13 |
+
{
|
14 |
+
if (null === $response) {
|
15 |
+
@\trigger_error('Instantiating the ' . __CLASS__ . ' class without a Response is deprecated since version 6.3 and will be removed in 7.0.', \E_USER_DEPRECATED);
|
16 |
+
}
|
17 |
+
parent::__construct($message, $request, $response, $previous, $handlerContext);
|
18 |
+
}
|
19 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exception when a client error is encountered (4xx codes)
|
7 |
+
*/
|
8 |
+
class ClientException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\BadResponseException
|
9 |
+
{
|
10 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
+
/**
|
7 |
+
* Exception thrown when a connection cannot be established.
|
8 |
+
*
|
9 |
+
* Note that no response is present for a ConnectException
|
10 |
+
*/
|
11 |
+
class ConnectException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException
|
12 |
+
{
|
13 |
+
public function __construct($message, \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \Exception $previous = null, array $handlerContext = [])
|
14 |
+
{
|
15 |
+
parent::__construct($message, $request, null, $previous, $handlerContext);
|
16 |
+
}
|
17 |
+
/**
|
18 |
+
* @return null
|
19 |
+
*/
|
20 |
+
public function getResponse()
|
21 |
+
{
|
22 |
+
return null;
|
23 |
+
}
|
24 |
+
/**
|
25 |
+
* @return bool
|
26 |
+
*/
|
27 |
+
public function hasResponse()
|
28 |
+
{
|
29 |
+
return \false;
|
30 |
+
}
|
31 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
use Throwable;
|
6 |
+
if (\interface_exists(\Throwable::class)) {
|
7 |
+
interface GuzzleException extends \Throwable
|
8 |
+
{
|
9 |
+
}
|
10 |
+
} else {
|
11 |
+
/**
|
12 |
+
* @method string getMessage()
|
13 |
+
* @method \Throwable|null getPrevious()
|
14 |
+
* @method mixed getCode()
|
15 |
+
* @method string getFile()
|
16 |
+
* @method int getLine()
|
17 |
+
* @method array getTrace()
|
18 |
+
* @method string getTraceAsString()
|
19 |
+
*/
|
20 |
+
interface GuzzleException
|
21 |
+
{
|
22 |
+
}
|
23 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
final class InvalidArgumentException extends \InvalidArgumentException implements \PixelCaffeine\Dependencies\GuzzleHttp\Exception\GuzzleException
|
6 |
+
{
|
7 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
9 |
+
/**
|
10 |
+
* HTTP Request exception
|
11 |
+
*/
|
12 |
+
class RequestException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\TransferException
|
13 |
+
{
|
14 |
+
/** @var RequestInterface */
|
15 |
+
private $request;
|
16 |
+
/** @var ResponseInterface|null */
|
17 |
+
private $response;
|
18 |
+
/** @var array */
|
19 |
+
private $handlerContext;
|
20 |
+
public function __construct($message, \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, \Exception $previous = null, array $handlerContext = [])
|
21 |
+
{
|
22 |
+
// Set the code of the exception if the response is set and not future.
|
23 |
+
$code = $response && !$response instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface ? $response->getStatusCode() : 0;
|
24 |
+
parent::__construct($message, $code, $previous);
|
25 |
+
$this->request = $request;
|
26 |
+
$this->response = $response;
|
27 |
+
$this->handlerContext = $handlerContext;
|
28 |
+
}
|
29 |
+
/**
|
30 |
+
* Wrap non-RequestExceptions with a RequestException
|
31 |
+
*
|
32 |
+
* @param RequestInterface $request
|
33 |
+
* @param \Exception $e
|
34 |
+
*
|
35 |
+
* @return RequestException
|
36 |
+
*/
|
37 |
+
public static function wrapException(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \Exception $e)
|
38 |
+
{
|
39 |
+
return $e instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException ? $e : new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException($e->getMessage(), $request, null, $e);
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* Factory method to create a new exception with a normalized error message
|
43 |
+
*
|
44 |
+
* @param RequestInterface $request Request
|
45 |
+
* @param ResponseInterface $response Response received
|
46 |
+
* @param \Exception $previous Previous exception
|
47 |
+
* @param array $ctx Optional handler context.
|
48 |
+
*
|
49 |
+
* @return self
|
50 |
+
*/
|
51 |
+
public static function create(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, \Exception $previous = null, array $ctx = [])
|
52 |
+
{
|
53 |
+
if (!$response) {
|
54 |
+
return new self('Error completing request', $request, null, $previous, $ctx);
|
55 |
+
}
|
56 |
+
$level = (int) \floor($response->getStatusCode() / 100);
|
57 |
+
if ($level === 4) {
|
58 |
+
$label = 'Client error';
|
59 |
+
$className = \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ClientException::class;
|
60 |
+
} elseif ($level === 5) {
|
61 |
+
$label = 'Server error';
|
62 |
+
$className = \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ServerException::class;
|
63 |
+
} else {
|
64 |
+
$label = 'Unsuccessful request';
|
65 |
+
$className = __CLASS__;
|
66 |
+
}
|
67 |
+
$uri = $request->getUri();
|
68 |
+
$uri = static::obfuscateUri($uri);
|
69 |
+
// Client Error: `GET /` resulted in a `404 Not Found` response:
|
70 |
+
// <html> ... (truncated)
|
71 |
+
$message = \sprintf('%s: `%s %s` resulted in a `%s %s` response', $label, $request->getMethod(), $uri, $response->getStatusCode(), $response->getReasonPhrase());
|
72 |
+
$summary = static::getResponseBodySummary($response);
|
73 |
+
if ($summary !== null) {
|
74 |
+
$message .= ":\n{$summary}\n";
|
75 |
+
}
|
76 |
+
return new $className($message, $request, $response, $previous, $ctx);
|
77 |
+
}
|
78 |
+
/**
|
79 |
+
* Get a short summary of the response
|
80 |
+
*
|
81 |
+
* Will return `null` if the response is not printable.
|
82 |
+
*
|
83 |
+
* @param ResponseInterface $response
|
84 |
+
*
|
85 |
+
* @return string|null
|
86 |
+
*/
|
87 |
+
public static function getResponseBodySummary(\PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response)
|
88 |
+
{
|
89 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\get_message_body_summary($response);
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* Obfuscates URI if there is a username and a password present
|
93 |
+
*
|
94 |
+
* @param UriInterface $uri
|
95 |
+
*
|
96 |
+
* @return UriInterface
|
97 |
+
*/
|
98 |
+
private static function obfuscateUri(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
99 |
+
{
|
100 |
+
$userInfo = $uri->getUserInfo();
|
101 |
+
if (\false !== ($pos = \strpos($userInfo, ':'))) {
|
102 |
+
return $uri->withUserInfo(\substr($userInfo, 0, $pos), '***');
|
103 |
+
}
|
104 |
+
return $uri;
|
105 |
+
}
|
106 |
+
/**
|
107 |
+
* Get the request that caused the exception
|
108 |
+
*
|
109 |
+
* @return RequestInterface
|
110 |
+
*/
|
111 |
+
public function getRequest()
|
112 |
+
{
|
113 |
+
return $this->request;
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* Get the associated response
|
117 |
+
*
|
118 |
+
* @return ResponseInterface|null
|
119 |
+
*/
|
120 |
+
public function getResponse()
|
121 |
+
{
|
122 |
+
return $this->response;
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* Check if a response was received
|
126 |
+
*
|
127 |
+
* @return bool
|
128 |
+
*/
|
129 |
+
public function hasResponse()
|
130 |
+
{
|
131 |
+
return $this->response !== null;
|
132 |
+
}
|
133 |
+
/**
|
134 |
+
* Get contextual information about the error from the underlying handler.
|
135 |
+
*
|
136 |
+
* The contents of this array will vary depending on which handler you are
|
137 |
+
* using. It may also be just an empty array. Relying on this data will
|
138 |
+
* couple you to a specific handler, but can give more debug information
|
139 |
+
* when needed.
|
140 |
+
*
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
public function getHandlerContext()
|
144 |
+
{
|
145 |
+
return $this->handlerContext;
|
146 |
+
}
|
147 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
+
/**
|
7 |
+
* Exception thrown when a seek fails on a stream.
|
8 |
+
*/
|
9 |
+
class SeekException extends \RuntimeException implements \PixelCaffeine\Dependencies\GuzzleHttp\Exception\GuzzleException
|
10 |
+
{
|
11 |
+
private $stream;
|
12 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, $pos = 0, $msg = '')
|
13 |
+
{
|
14 |
+
$this->stream = $stream;
|
15 |
+
$msg = $msg ?: 'Could not seek the stream to position ' . $pos;
|
16 |
+
parent::__construct($msg);
|
17 |
+
}
|
18 |
+
/**
|
19 |
+
* @return StreamInterface
|
20 |
+
*/
|
21 |
+
public function getStream()
|
22 |
+
{
|
23 |
+
return $this->stream;
|
24 |
+
}
|
25 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exception when a server error is encountered (5xx codes)
|
7 |
+
*/
|
8 |
+
class ServerException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\BadResponseException
|
9 |
+
{
|
10 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
class TooManyRedirectsException extends \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException
|
6 |
+
{
|
7 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Exception;
|
4 |
+
|
5 |
+
class TransferException extends \RuntimeException implements \PixelCaffeine\Dependencies\GuzzleHttp\Exception\GuzzleException
|
6 |
+
{
|
7 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlFactory.php
RENAMED
@@ -1,57 +1,39 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Handler;
|
4 |
-
|
5 |
-
use GuzzleHttp\Exception\ConnectException;
|
6 |
-
use GuzzleHttp\Exception\RequestException;
|
7 |
-
use GuzzleHttp\Promise
|
8 |
-
use GuzzleHttp\
|
9 |
-
use GuzzleHttp\
|
10 |
-
use GuzzleHttp\
|
11 |
-
use
|
12 |
-
use GuzzleHttp\Utils;
|
13 |
-
use Psr\Http\Message\RequestInterface;
|
14 |
-
|
15 |
/**
|
16 |
* Creates curl resources from a request
|
17 |
-
*
|
18 |
-
* @final
|
19 |
*/
|
20 |
-
class CurlFactory implements CurlFactoryInterface
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @deprecated
|
26 |
-
*/
|
27 |
-
public const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var resource[]|\CurlHandle[]
|
31 |
-
*/
|
32 |
private $handles = [];
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @var int Total number of idle handles to keep in cache
|
36 |
-
*/
|
37 |
private $maxHandles;
|
38 |
-
|
39 |
/**
|
40 |
* @param int $maxHandles Maximum number of idle handles.
|
41 |
*/
|
42 |
-
public function __construct(
|
43 |
{
|
44 |
$this->maxHandles = $maxHandles;
|
45 |
}
|
46 |
-
|
47 |
-
public function create(RequestInterface $request, array $options): EasyHandle
|
48 |
{
|
49 |
if (isset($options['curl']['body_as_string'])) {
|
50 |
$options['_body_as_string'] = $options['curl']['body_as_string'];
|
51 |
unset($options['curl']['body_as_string']);
|
52 |
}
|
53 |
-
|
54 |
-
$easy = new EasyHandle;
|
55 |
$easy->request = $request;
|
56 |
$easy->options = $options;
|
57 |
$conf = $this->getDefaultConf($easy);
|
@@ -59,24 +41,19 @@ class CurlFactory implements CurlFactoryInterface
|
|
59 |
$this->applyHandlerOptions($easy, $conf);
|
60 |
$this->applyHeaders($easy, $conf);
|
61 |
unset($conf['_headers']);
|
62 |
-
|
63 |
// Add handler options from the request configuration options
|
64 |
if (isset($options['curl'])) {
|
65 |
$conf = \array_replace($conf, $options['curl']);
|
66 |
}
|
67 |
-
|
68 |
$conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
|
69 |
$easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
|
70 |
-
curl_setopt_array($easy->handle, $conf);
|
71 |
-
|
72 |
return $easy;
|
73 |
}
|
74 |
-
|
75 |
-
public function release(EasyHandle $easy): void
|
76 |
{
|
77 |
$resource = $easy->handle;
|
78 |
unset($easy->handle);
|
79 |
-
|
80 |
if (\count($this->handles) >= $this->maxHandles) {
|
81 |
\curl_close($resource);
|
82 |
} else {
|
@@ -92,145 +69,75 @@ class CurlFactory implements CurlFactoryInterface
|
|
92 |
$this->handles[] = $resource;
|
93 |
}
|
94 |
}
|
95 |
-
|
96 |
/**
|
97 |
* Completes a cURL transaction, either returning a response promise or a
|
98 |
* rejected promise.
|
99 |
*
|
100 |
-
* @param callable
|
101 |
-
* @param
|
|
|
|
|
|
|
102 |
*/
|
103 |
-
public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory)
|
104 |
{
|
105 |
if (isset($easy->options['on_stats'])) {
|
106 |
self::invokeStats($easy);
|
107 |
}
|
108 |
-
|
109 |
if (!$easy->response || $easy->errno) {
|
110 |
return self::finishError($handler, $easy, $factory);
|
111 |
}
|
112 |
-
|
113 |
// Return the response if it is present and there is no error.
|
114 |
$factory->release($easy);
|
115 |
-
|
116 |
// Rewind the body of the response if possible.
|
117 |
$body = $easy->response->getBody();
|
118 |
if ($body->isSeekable()) {
|
119 |
$body->rewind();
|
120 |
}
|
121 |
-
|
122 |
-
return new FulfilledPromise($easy->response);
|
123 |
}
|
124 |
-
|
125 |
-
private static function invokeStats(EasyHandle $easy): void
|
126 |
{
|
127 |
$curlStats = \curl_getinfo($easy->handle);
|
128 |
$curlStats['appconnect_time'] = \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME);
|
129 |
-
$stats = new TransferStats(
|
130 |
-
|
131 |
-
$easy->response,
|
132 |
-
$curlStats['total_time'],
|
133 |
-
$easy->errno,
|
134 |
-
$curlStats
|
135 |
-
);
|
136 |
-
($easy->options['on_stats'])($stats);
|
137 |
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param callable(RequestInterface, array): PromiseInterface $handler
|
141 |
-
*/
|
142 |
-
private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
|
143 |
{
|
144 |
// Get error information and release the handle to the factory.
|
145 |
-
$ctx = [
|
146 |
-
'errno' => $easy->errno,
|
147 |
-
'error' => \curl_error($easy->handle),
|
148 |
-
'appconnect_time' => \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME),
|
149 |
-
] + \curl_getinfo($easy->handle);
|
150 |
$ctx[self::CURL_VERSION_STR] = \curl_version()['version'];
|
151 |
$factory->release($easy);
|
152 |
-
|
153 |
// Retry when nothing is present or when curl failed to rewind.
|
154 |
if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
|
155 |
return self::retryFailedRewind($handler, $easy, $ctx);
|
156 |
}
|
157 |
-
|
158 |
return self::createRejection($easy, $ctx);
|
159 |
}
|
160 |
-
|
161 |
-
private static function createRejection(EasyHandle $easy, array $ctx): PromiseInterface
|
162 |
{
|
163 |
-
static $connectionErrors = [
|
164 |
-
\CURLE_OPERATION_TIMEOUTED => true,
|
165 |
-
\CURLE_COULDNT_RESOLVE_HOST => true,
|
166 |
-
\CURLE_COULDNT_CONNECT => true,
|
167 |
-
\CURLE_SSL_CONNECT_ERROR => true,
|
168 |
-
\CURLE_GOT_NOTHING => true,
|
169 |
-
];
|
170 |
-
|
171 |
-
if ($easy->createResponseException) {
|
172 |
-
return P\Create::rejectionFor(
|
173 |
-
new RequestException(
|
174 |
-
'An error was encountered while creating the response',
|
175 |
-
$easy->request,
|
176 |
-
$easy->response,
|
177 |
-
$easy->createResponseException,
|
178 |
-
$ctx
|
179 |
-
)
|
180 |
-
);
|
181 |
-
}
|
182 |
-
|
183 |
// If an exception was encountered during the onHeaders event, then
|
184 |
// return a rejected promise that wraps that exception.
|
185 |
if ($easy->onHeadersException) {
|
186 |
-
return
|
187 |
-
new RequestException(
|
188 |
-
'An error was encountered during the on_headers event',
|
189 |
-
$easy->request,
|
190 |
-
$easy->response,
|
191 |
-
$easy->onHeadersException,
|
192 |
-
$ctx
|
193 |
-
)
|
194 |
-
);
|
195 |
}
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
$ctx['errno'],
|
200 |
-
$ctx['error'],
|
201 |
-
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
202 |
-
);
|
203 |
-
$uriString = (string) $easy->request->getUri();
|
204 |
-
if ($uriString !== '' && false === \strpos($ctx['error'], $uriString)) {
|
205 |
-
$message .= \sprintf(' for %s', $uriString);
|
206 |
}
|
207 |
-
|
208 |
// Create a connection exception if it was a specific error code.
|
209 |
-
$error = isset($connectionErrors[$easy->errno])
|
210 |
-
|
211 |
-
: new RequestException($message, $easy->request, $easy->response, null, $ctx);
|
212 |
-
|
213 |
-
return P\Create::rejectionFor($error);
|
214 |
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* @return array<int|string, mixed>
|
218 |
-
*/
|
219 |
-
private function getDefaultConf(EasyHandle $easy): array
|
220 |
{
|
221 |
-
$conf = [
|
222 |
-
'_headers' => $easy->request->getHeaders(),
|
223 |
-
\CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
|
224 |
-
\CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
|
225 |
-
\CURLOPT_RETURNTRANSFER => false,
|
226 |
-
\CURLOPT_HEADER => false,
|
227 |
-
\CURLOPT_CONNECTTIMEOUT => 150,
|
228 |
-
];
|
229 |
-
|
230 |
if (\defined('CURLOPT_PROTOCOLS')) {
|
231 |
$conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS;
|
232 |
}
|
233 |
-
|
234 |
$version = $easy->request->getProtocolVersion();
|
235 |
if ($version == 1.1) {
|
236 |
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1;
|
@@ -239,52 +146,39 @@ class CurlFactory implements CurlFactoryInterface
|
|
239 |
} else {
|
240 |
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_0;
|
241 |
}
|
242 |
-
|
243 |
return $conf;
|
244 |
}
|
245 |
-
|
246 |
-
private function applyMethod(EasyHandle $easy, array &$conf): void
|
247 |
{
|
248 |
$body = $easy->request->getBody();
|
249 |
$size = $body->getSize();
|
250 |
-
|
251 |
if ($size === null || $size > 0) {
|
252 |
$this->applyBody($easy->request, $easy->options, $conf);
|
253 |
return;
|
254 |
}
|
255 |
-
|
256 |
$method = $easy->request->getMethod();
|
257 |
if ($method === 'PUT' || $method === 'POST') {
|
258 |
-
// See
|
259 |
if (!$easy->request->hasHeader('Content-Length')) {
|
260 |
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
|
261 |
}
|
262 |
} elseif ($method === 'HEAD') {
|
263 |
-
$conf[\CURLOPT_NOBODY] = true;
|
264 |
-
unset(
|
265 |
-
$conf[\CURLOPT_WRITEFUNCTION],
|
266 |
-
$conf[\CURLOPT_READFUNCTION],
|
267 |
-
$conf[\CURLOPT_FILE],
|
268 |
-
$conf[\CURLOPT_INFILE]
|
269 |
-
);
|
270 |
}
|
271 |
}
|
272 |
-
|
273 |
-
private function applyBody(RequestInterface $request, array $options, array &$conf): void
|
274 |
{
|
275 |
-
$size = $request->hasHeader('Content-Length')
|
276 |
-
? (int) $request->getHeaderLine('Content-Length')
|
277 |
-
: null;
|
278 |
-
|
279 |
// Send the body as a string if the size is less than 1MB OR if the
|
280 |
// [curl][body_as_string] request value is set.
|
281 |
-
if (
|
282 |
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
|
283 |
// Don't duplicate the Content-Length header
|
284 |
$this->removeHeader('Content-Length', $conf);
|
285 |
$this->removeHeader('Transfer-Encoding', $conf);
|
286 |
} else {
|
287 |
-
$conf[\CURLOPT_UPLOAD] = true;
|
288 |
if ($size !== null) {
|
289 |
$conf[\CURLOPT_INFILESIZE] = $size;
|
290 |
$this->removeHeader('Content-Length', $conf);
|
@@ -293,23 +187,20 @@ class CurlFactory implements CurlFactoryInterface
|
|
293 |
if ($body->isSeekable()) {
|
294 |
$body->rewind();
|
295 |
}
|
296 |
-
$conf[\CURLOPT_READFUNCTION] =
|
297 |
return $body->read($length);
|
298 |
};
|
299 |
}
|
300 |
-
|
301 |
// If the Expect header is not present, prevent curl from adding it
|
302 |
if (!$request->hasHeader('Expect')) {
|
303 |
$conf[\CURLOPT_HTTPHEADER][] = 'Expect:';
|
304 |
}
|
305 |
-
|
306 |
// cURL sometimes adds a content-type by default. Prevent this.
|
307 |
if (!$request->hasHeader('Content-Type')) {
|
308 |
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Type:';
|
309 |
}
|
310 |
}
|
311 |
-
|
312 |
-
private function applyHeaders(EasyHandle $easy, array &$conf): void
|
313 |
{
|
314 |
foreach ($conf['_headers'] as $name => $values) {
|
315 |
foreach ($values as $value) {
|
@@ -317,26 +208,24 @@ class CurlFactory implements CurlFactoryInterface
|
|
317 |
if ($value === '') {
|
318 |
// cURL requires a special format for empty headers.
|
319 |
// See https://github.com/guzzle/guzzle/issues/1882 for more details.
|
320 |
-
$conf[\CURLOPT_HTTPHEADER][] = "$name;";
|
321 |
} else {
|
322 |
-
$conf[\CURLOPT_HTTPHEADER][] = "$name: $value";
|
323 |
}
|
324 |
}
|
325 |
}
|
326 |
-
|
327 |
// Remove the Accept header if one was not set
|
328 |
if (!$easy->request->hasHeader('Accept')) {
|
329 |
$conf[\CURLOPT_HTTPHEADER][] = 'Accept:';
|
330 |
}
|
331 |
}
|
332 |
-
|
333 |
/**
|
334 |
* Remove a header from the options array.
|
335 |
*
|
336 |
* @param string $name Case-insensitive header to remove
|
337 |
* @param array $options Array of options to modify
|
338 |
*/
|
339 |
-
private function removeHeader(
|
340 |
{
|
341 |
foreach (\array_keys($options['_headers']) as $key) {
|
342 |
if (!\strcasecmp($key, $name)) {
|
@@ -345,18 +234,17 @@ class CurlFactory implements CurlFactoryInterface
|
|
345 |
}
|
346 |
}
|
347 |
}
|
348 |
-
|
349 |
-
private function applyHandlerOptions(EasyHandle $easy, array &$conf): void
|
350 |
{
|
351 |
$options = $easy->options;
|
352 |
if (isset($options['verify'])) {
|
353 |
-
if ($options['verify'] === false) {
|
354 |
unset($conf[\CURLOPT_CAINFO]);
|
355 |
$conf[\CURLOPT_SSL_VERIFYHOST] = 0;
|
356 |
-
$conf[\CURLOPT_SSL_VERIFYPEER] = false;
|
357 |
} else {
|
358 |
$conf[\CURLOPT_SSL_VERIFYHOST] = 2;
|
359 |
-
$conf[\CURLOPT_SSL_VERIFYPEER] = true;
|
360 |
if (\is_string($options['verify'])) {
|
361 |
// Throw an error if the file/folder/link path is not valid or doesn't exist.
|
362 |
if (!\file_exists($options['verify'])) {
|
@@ -364,14 +252,7 @@ class CurlFactory implements CurlFactoryInterface
|
|
364 |
}
|
365 |
// If it's a directory or a link to a directory use CURLOPT_CAPATH.
|
366 |
// If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
|
367 |
-
if (
|
368 |
-
\is_dir($options['verify']) ||
|
369 |
-
(
|
370 |
-
\is_link($options['verify']) === true &&
|
371 |
-
($verifyLink = \readlink($options['verify'])) !== false &&
|
372 |
-
\is_dir($verifyLink)
|
373 |
-
)
|
374 |
-
) {
|
375 |
$conf[\CURLOPT_CAPATH] = $options['verify'];
|
376 |
} else {
|
377 |
$conf[\CURLOPT_CAINFO] = $options['verify'];
|
@@ -379,8 +260,7 @@ class CurlFactory implements CurlFactoryInterface
|
|
379 |
}
|
380 |
}
|
381 |
}
|
382 |
-
|
383 |
-
if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) {
|
384 |
$accept = $easy->request->getHeaderLine('Accept-Encoding');
|
385 |
if ($accept) {
|
386 |
$conf[\CURLOPT_ENCODING] = $accept;
|
@@ -390,31 +270,30 @@ class CurlFactory implements CurlFactoryInterface
|
|
390 |
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
|
391 |
}
|
392 |
}
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
|
|
|
|
|
|
404 |
} else {
|
405 |
-
|
|
|
|
|
406 |
}
|
407 |
-
$
|
408 |
-
$conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int {
|
409 |
-
return $sink->write($write);
|
410 |
-
};
|
411 |
-
|
412 |
-
$timeoutRequiresNoSignal = false;
|
413 |
if (isset($options['timeout'])) {
|
414 |
$timeoutRequiresNoSignal |= $options['timeout'] < 1;
|
415 |
$conf[\CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
|
416 |
}
|
417 |
-
|
418 |
// CURL default value is CURL_IPRESOLVE_WHATEVER
|
419 |
if (isset($options['force_ip_resolve'])) {
|
420 |
if ('v4' === $options['force_ip_resolve']) {
|
@@ -423,16 +302,13 @@ class CurlFactory implements CurlFactoryInterface
|
|
423 |
$conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V6;
|
424 |
}
|
425 |
}
|
426 |
-
|
427 |
if (isset($options['connect_timeout'])) {
|
428 |
$timeoutRequiresNoSignal |= $options['connect_timeout'] < 1;
|
429 |
$conf[\CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
|
430 |
}
|
431 |
-
|
432 |
if ($timeoutRequiresNoSignal && \strtoupper(\substr(\PHP_OS, 0, 3)) !== 'WIN') {
|
433 |
-
$conf[\CURLOPT_NOSIGNAL] = true;
|
434 |
}
|
435 |
-
|
436 |
if (isset($options['proxy'])) {
|
437 |
if (!\is_array($options['proxy'])) {
|
438 |
$conf[\CURLOPT_PROXY] = $options['proxy'];
|
@@ -440,13 +316,12 @@ class CurlFactory implements CurlFactoryInterface
|
|
440 |
$scheme = $easy->request->getUri()->getScheme();
|
441 |
if (isset($options['proxy'][$scheme])) {
|
442 |
$host = $easy->request->getUri()->getHost();
|
443 |
-
if (!isset($options['proxy']['no']) ||
|
444 |
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
445 |
}
|
446 |
}
|
447 |
}
|
448 |
}
|
449 |
-
|
450 |
if (isset($options['cert'])) {
|
451 |
$cert = $options['cert'];
|
452 |
if (\is_array($cert)) {
|
@@ -458,41 +333,40 @@ class CurlFactory implements CurlFactoryInterface
|
|
458 |
}
|
459 |
$conf[\CURLOPT_SSLCERT] = $cert;
|
460 |
}
|
461 |
-
|
462 |
if (isset($options['ssl_key'])) {
|
463 |
if (\is_array($options['ssl_key'])) {
|
464 |
if (\count($options['ssl_key']) === 2) {
|
465 |
-
|
466 |
} else {
|
467 |
-
|
468 |
}
|
469 |
}
|
470 |
-
|
471 |
-
$sslKey = $sslKey ?? $options['ssl_key'];
|
472 |
-
|
473 |
if (!\file_exists($sslKey)) {
|
474 |
throw new \InvalidArgumentException("SSL private key not found: {$sslKey}");
|
475 |
}
|
476 |
$conf[\CURLOPT_SSLKEY] = $sslKey;
|
477 |
}
|
478 |
-
|
479 |
if (isset($options['progress'])) {
|
480 |
$progress = $options['progress'];
|
481 |
if (!\is_callable($progress)) {
|
482 |
throw new \InvalidArgumentException('progress client option must be callable');
|
483 |
}
|
484 |
-
$conf[\CURLOPT_NOPROGRESS] = false;
|
485 |
-
$conf[\CURLOPT_PROGRESSFUNCTION] =
|
486 |
-
$
|
|
|
|
|
|
|
|
|
|
|
487 |
};
|
488 |
}
|
489 |
-
|
490 |
if (!empty($options['debug'])) {
|
491 |
-
$conf[\CURLOPT_STDERR] =
|
492 |
-
$conf[\CURLOPT_VERBOSE] = true;
|
493 |
}
|
494 |
}
|
495 |
-
|
496 |
/**
|
497 |
* This function ensures that a response was set on a transaction. If one
|
498 |
* was not set, then the request is retried if possible. This error
|
@@ -501,10 +375,8 @@ class CurlFactory implements CurlFactoryInterface
|
|
501 |
* stream, and then encountered a "necessary data rewind wasn't possible"
|
502 |
* error, causing the request to be sent through curl_multi_info_read()
|
503 |
* without an error status.
|
504 |
-
*
|
505 |
-
* @param callable(RequestInterface, array): PromiseInterface $handler
|
506 |
*/
|
507 |
-
private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx)
|
508 |
{
|
509 |
try {
|
510 |
// Only rewind if the body has been read from.
|
@@ -513,57 +385,35 @@ class CurlFactory implements CurlFactoryInterface
|
|
513 |
$body->rewind();
|
514 |
}
|
515 |
} catch (\RuntimeException $e) {
|
516 |
-
$ctx['error'] = 'The connection unexpectedly failed without '
|
517 |
-
. 'providing an error. The request would have been retried, '
|
518 |
-
. 'but attempting to rewind the request body failed. '
|
519 |
-
. 'Exception: ' . $e;
|
520 |
return self::createRejection($easy, $ctx);
|
521 |
}
|
522 |
-
|
523 |
// Retry no more than 3 times before giving up.
|
524 |
if (!isset($easy->options['_curl_retries'])) {
|
525 |
$easy->options['_curl_retries'] = 1;
|
526 |
} elseif ($easy->options['_curl_retries'] == 2) {
|
527 |
-
$ctx['error'] = 'The cURL request was retried 3 times '
|
528 |
-
. 'and did not succeed. The most likely reason for the failure '
|
529 |
-
. 'is that cURL was unable to rewind the body of the request '
|
530 |
-
. 'and subsequent retries resulted in the same error. Turn on '
|
531 |
-
. 'the debug option to see what went wrong. See '
|
532 |
-
. 'https://bugs.php.net/bug.php?id=47204 for more information.';
|
533 |
return self::createRejection($easy, $ctx);
|
534 |
} else {
|
535 |
$easy->options['_curl_retries']++;
|
536 |
}
|
537 |
-
|
538 |
return $handler($easy->request, $easy->options);
|
539 |
}
|
540 |
-
|
541 |
-
private function createHeaderFn(EasyHandle $easy): callable
|
542 |
{
|
543 |
if (isset($easy->options['on_headers'])) {
|
544 |
$onHeaders = $easy->options['on_headers'];
|
545 |
-
|
546 |
if (!\is_callable($onHeaders)) {
|
547 |
throw new \InvalidArgumentException('on_headers must be callable');
|
548 |
}
|
549 |
} else {
|
550 |
$onHeaders = null;
|
551 |
}
|
552 |
-
|
553 |
-
return static function ($ch, $h) use (
|
554 |
-
$onHeaders,
|
555 |
-
$easy,
|
556 |
-
&$startingResponse
|
557 |
-
) {
|
558 |
$value = \trim($h);
|
559 |
if ($value === '') {
|
560 |
-
$startingResponse = true;
|
561 |
-
|
562 |
-
$easy->createResponse();
|
563 |
-
} catch (\Exception $e) {
|
564 |
-
$easy->createResponseException = $e;
|
565 |
-
return -1;
|
566 |
-
}
|
567 |
if ($onHeaders !== null) {
|
568 |
try {
|
569 |
$onHeaders($easy->response);
|
@@ -575,7 +425,7 @@ class CurlFactory implements CurlFactoryInterface
|
|
575 |
}
|
576 |
}
|
577 |
} elseif ($startingResponse) {
|
578 |
-
$startingResponse = false;
|
579 |
$easy->headers = [$value];
|
580 |
} else {
|
581 |
$easy->headers[] = $value;
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\FulfilledPromise;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
9 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream;
|
10 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\TransferStats;
|
11 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Creates curl resources from a request
|
|
|
|
|
14 |
*/
|
15 |
+
class CurlFactory implements \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactoryInterface
|
16 |
{
|
17 |
+
const CURL_VERSION_STR = 'curl_version';
|
18 |
+
const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
19 |
+
/** @var array */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
private $handles = [];
|
21 |
+
/** @var int Total number of idle handles to keep in cache */
|
|
|
|
|
|
|
22 |
private $maxHandles;
|
|
|
23 |
/**
|
24 |
* @param int $maxHandles Maximum number of idle handles.
|
25 |
*/
|
26 |
+
public function __construct($maxHandles)
|
27 |
{
|
28 |
$this->maxHandles = $maxHandles;
|
29 |
}
|
30 |
+
public function create(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
|
|
31 |
{
|
32 |
if (isset($options['curl']['body_as_string'])) {
|
33 |
$options['_body_as_string'] = $options['curl']['body_as_string'];
|
34 |
unset($options['curl']['body_as_string']);
|
35 |
}
|
36 |
+
$easy = new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle();
|
|
|
37 |
$easy->request = $request;
|
38 |
$easy->options = $options;
|
39 |
$conf = $this->getDefaultConf($easy);
|
41 |
$this->applyHandlerOptions($easy, $conf);
|
42 |
$this->applyHeaders($easy, $conf);
|
43 |
unset($conf['_headers']);
|
|
|
44 |
// Add handler options from the request configuration options
|
45 |
if (isset($options['curl'])) {
|
46 |
$conf = \array_replace($conf, $options['curl']);
|
47 |
}
|
|
|
48 |
$conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
|
49 |
$easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
|
50 |
+
\curl_setopt_array($easy->handle, $conf);
|
|
|
51 |
return $easy;
|
52 |
}
|
53 |
+
public function release(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy)
|
|
|
54 |
{
|
55 |
$resource = $easy->handle;
|
56 |
unset($easy->handle);
|
|
|
57 |
if (\count($this->handles) >= $this->maxHandles) {
|
58 |
\curl_close($resource);
|
59 |
} else {
|
69 |
$this->handles[] = $resource;
|
70 |
}
|
71 |
}
|
|
|
72 |
/**
|
73 |
* Completes a cURL transaction, either returning a response promise or a
|
74 |
* rejected promise.
|
75 |
*
|
76 |
+
* @param callable $handler
|
77 |
+
* @param EasyHandle $easy
|
78 |
+
* @param CurlFactoryInterface $factory Dictates how the handle is released
|
79 |
+
*
|
80 |
+
* @return \GuzzleHttp\Promise\PromiseInterface
|
81 |
*/
|
82 |
+
public static function finish(callable $handler, \PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactoryInterface $factory)
|
83 |
{
|
84 |
if (isset($easy->options['on_stats'])) {
|
85 |
self::invokeStats($easy);
|
86 |
}
|
|
|
87 |
if (!$easy->response || $easy->errno) {
|
88 |
return self::finishError($handler, $easy, $factory);
|
89 |
}
|
|
|
90 |
// Return the response if it is present and there is no error.
|
91 |
$factory->release($easy);
|
|
|
92 |
// Rewind the body of the response if possible.
|
93 |
$body = $easy->response->getBody();
|
94 |
if ($body->isSeekable()) {
|
95 |
$body->rewind();
|
96 |
}
|
97 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\FulfilledPromise($easy->response);
|
|
|
98 |
}
|
99 |
+
private static function invokeStats(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy)
|
|
|
100 |
{
|
101 |
$curlStats = \curl_getinfo($easy->handle);
|
102 |
$curlStats['appconnect_time'] = \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME);
|
103 |
+
$stats = new \PixelCaffeine\Dependencies\GuzzleHttp\TransferStats($easy->request, $easy->response, $curlStats['total_time'], $easy->errno, $curlStats);
|
104 |
+
\call_user_func($easy->options['on_stats'], $stats);
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
+
private static function finishError(callable $handler, \PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactoryInterface $factory)
|
|
|
|
|
|
|
|
|
107 |
{
|
108 |
// Get error information and release the handle to the factory.
|
109 |
+
$ctx = ['errno' => $easy->errno, 'error' => \curl_error($easy->handle), 'appconnect_time' => \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME)] + \curl_getinfo($easy->handle);
|
|
|
|
|
|
|
|
|
110 |
$ctx[self::CURL_VERSION_STR] = \curl_version()['version'];
|
111 |
$factory->release($easy);
|
|
|
112 |
// Retry when nothing is present or when curl failed to rewind.
|
113 |
if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
|
114 |
return self::retryFailedRewind($handler, $easy, $ctx);
|
115 |
}
|
|
|
116 |
return self::createRejection($easy, $ctx);
|
117 |
}
|
118 |
+
private static function createRejection(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, array $ctx)
|
|
|
119 |
{
|
120 |
+
static $connectionErrors = [\CURLE_OPERATION_TIMEOUTED => \true, \CURLE_COULDNT_RESOLVE_HOST => \true, \CURLE_COULDNT_CONNECT => \true, \CURLE_SSL_CONNECT_ERROR => \true, \CURLE_GOT_NOTHING => \true];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
// If an exception was encountered during the onHeaders event, then
|
122 |
// return a rejected promise that wraps that exception.
|
123 |
if ($easy->onHeadersException) {
|
124 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for(new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException('An error was encountered during the on_headers event', $easy->request, $easy->response, $easy->onHeadersException, $ctx));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
+
if (\version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) {
|
127 |
+
$message = \sprintf('cURL error %s: %s (%s)', $ctx['errno'], $ctx['error'], 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html');
|
128 |
+
} else {
|
129 |
+
$message = \sprintf('cURL error %s: %s (%s) for %s', $ctx['errno'], $ctx['error'], 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html', $easy->request->getUri());
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
|
|
131 |
// Create a connection exception if it was a specific error code.
|
132 |
+
$error = isset($connectionErrors[$easy->errno]) ? new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException($message, $easy->request, null, $ctx) : new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException($message, $easy->request, $easy->response, null, $ctx);
|
133 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($error);
|
|
|
|
|
|
|
134 |
}
|
135 |
+
private function getDefaultConf(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy)
|
|
|
|
|
|
|
|
|
136 |
{
|
137 |
+
$conf = ['_headers' => $easy->request->getHeaders(), \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => \false, \CURLOPT_HEADER => \false, \CURLOPT_CONNECTTIMEOUT => 150];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
if (\defined('CURLOPT_PROTOCOLS')) {
|
139 |
$conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS;
|
140 |
}
|
|
|
141 |
$version = $easy->request->getProtocolVersion();
|
142 |
if ($version == 1.1) {
|
143 |
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1;
|
146 |
} else {
|
147 |
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_0;
|
148 |
}
|
|
|
149 |
return $conf;
|
150 |
}
|
151 |
+
private function applyMethod(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, array &$conf)
|
|
|
152 |
{
|
153 |
$body = $easy->request->getBody();
|
154 |
$size = $body->getSize();
|
|
|
155 |
if ($size === null || $size > 0) {
|
156 |
$this->applyBody($easy->request, $easy->options, $conf);
|
157 |
return;
|
158 |
}
|
|
|
159 |
$method = $easy->request->getMethod();
|
160 |
if ($method === 'PUT' || $method === 'POST') {
|
161 |
+
// See http://tools.ietf.org/html/rfc7230#section-3.3.2
|
162 |
if (!$easy->request->hasHeader('Content-Length')) {
|
163 |
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
|
164 |
}
|
165 |
} elseif ($method === 'HEAD') {
|
166 |
+
$conf[\CURLOPT_NOBODY] = \true;
|
167 |
+
unset($conf[\CURLOPT_WRITEFUNCTION], $conf[\CURLOPT_READFUNCTION], $conf[\CURLOPT_FILE], $conf[\CURLOPT_INFILE]);
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
}
|
170 |
+
private function applyBody(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, array &$conf)
|
|
|
171 |
{
|
172 |
+
$size = $request->hasHeader('Content-Length') ? (int) $request->getHeaderLine('Content-Length') : null;
|
|
|
|
|
|
|
173 |
// Send the body as a string if the size is less than 1MB OR if the
|
174 |
// [curl][body_as_string] request value is set.
|
175 |
+
if ($size !== null && $size < 1000000 || !empty($options['_body_as_string'])) {
|
176 |
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
|
177 |
// Don't duplicate the Content-Length header
|
178 |
$this->removeHeader('Content-Length', $conf);
|
179 |
$this->removeHeader('Transfer-Encoding', $conf);
|
180 |
} else {
|
181 |
+
$conf[\CURLOPT_UPLOAD] = \true;
|
182 |
if ($size !== null) {
|
183 |
$conf[\CURLOPT_INFILESIZE] = $size;
|
184 |
$this->removeHeader('Content-Length', $conf);
|
187 |
if ($body->isSeekable()) {
|
188 |
$body->rewind();
|
189 |
}
|
190 |
+
$conf[\CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use($body) {
|
191 |
return $body->read($length);
|
192 |
};
|
193 |
}
|
|
|
194 |
// If the Expect header is not present, prevent curl from adding it
|
195 |
if (!$request->hasHeader('Expect')) {
|
196 |
$conf[\CURLOPT_HTTPHEADER][] = 'Expect:';
|
197 |
}
|
|
|
198 |
// cURL sometimes adds a content-type by default. Prevent this.
|
199 |
if (!$request->hasHeader('Content-Type')) {
|
200 |
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Type:';
|
201 |
}
|
202 |
}
|
203 |
+
private function applyHeaders(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, array &$conf)
|
|
|
204 |
{
|
205 |
foreach ($conf['_headers'] as $name => $values) {
|
206 |
foreach ($values as $value) {
|
208 |
if ($value === '') {
|
209 |
// cURL requires a special format for empty headers.
|
210 |
// See https://github.com/guzzle/guzzle/issues/1882 for more details.
|
211 |
+
$conf[\CURLOPT_HTTPHEADER][] = "{$name};";
|
212 |
} else {
|
213 |
+
$conf[\CURLOPT_HTTPHEADER][] = "{$name}: {$value}";
|
214 |
}
|
215 |
}
|
216 |
}
|
|
|
217 |
// Remove the Accept header if one was not set
|
218 |
if (!$easy->request->hasHeader('Accept')) {
|
219 |
$conf[\CURLOPT_HTTPHEADER][] = 'Accept:';
|
220 |
}
|
221 |
}
|
|
|
222 |
/**
|
223 |
* Remove a header from the options array.
|
224 |
*
|
225 |
* @param string $name Case-insensitive header to remove
|
226 |
* @param array $options Array of options to modify
|
227 |
*/
|
228 |
+
private function removeHeader($name, array &$options)
|
229 |
{
|
230 |
foreach (\array_keys($options['_headers']) as $key) {
|
231 |
if (!\strcasecmp($key, $name)) {
|
234 |
}
|
235 |
}
|
236 |
}
|
237 |
+
private function applyHandlerOptions(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, array &$conf)
|
|
|
238 |
{
|
239 |
$options = $easy->options;
|
240 |
if (isset($options['verify'])) {
|
241 |
+
if ($options['verify'] === \false) {
|
242 |
unset($conf[\CURLOPT_CAINFO]);
|
243 |
$conf[\CURLOPT_SSL_VERIFYHOST] = 0;
|
244 |
+
$conf[\CURLOPT_SSL_VERIFYPEER] = \false;
|
245 |
} else {
|
246 |
$conf[\CURLOPT_SSL_VERIFYHOST] = 2;
|
247 |
+
$conf[\CURLOPT_SSL_VERIFYPEER] = \true;
|
248 |
if (\is_string($options['verify'])) {
|
249 |
// Throw an error if the file/folder/link path is not valid or doesn't exist.
|
250 |
if (!\file_exists($options['verify'])) {
|
252 |
}
|
253 |
// If it's a directory or a link to a directory use CURLOPT_CAPATH.
|
254 |
// If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
|
255 |
+
if (\is_dir($options['verify']) || \is_link($options['verify']) && \is_dir(\readlink($options['verify']))) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
$conf[\CURLOPT_CAPATH] = $options['verify'];
|
257 |
} else {
|
258 |
$conf[\CURLOPT_CAINFO] = $options['verify'];
|
260 |
}
|
261 |
}
|
262 |
}
|
263 |
+
if (!empty($options['decode_content'])) {
|
|
|
264 |
$accept = $easy->request->getHeaderLine('Accept-Encoding');
|
265 |
if ($accept) {
|
266 |
$conf[\CURLOPT_ENCODING] = $accept;
|
270 |
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
|
271 |
}
|
272 |
}
|
273 |
+
if (isset($options['sink'])) {
|
274 |
+
$sink = $options['sink'];
|
275 |
+
if (!\is_string($sink)) {
|
276 |
+
$sink = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($sink);
|
277 |
+
} elseif (!\is_dir(\dirname($sink))) {
|
278 |
+
// Ensure that the directory exists before failing in curl.
|
279 |
+
throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink));
|
280 |
+
} else {
|
281 |
+
$sink = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream($sink, 'w+');
|
282 |
+
}
|
283 |
+
$easy->sink = $sink;
|
284 |
+
$conf[\CURLOPT_WRITEFUNCTION] = function ($ch, $write) use($sink) {
|
285 |
+
return $sink->write($write);
|
286 |
+
};
|
287 |
} else {
|
288 |
+
// Use a default temp stream if no sink was set.
|
289 |
+
$conf[\CURLOPT_FILE] = \fopen('php://temp', 'w+');
|
290 |
+
$easy->sink = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($conf[\CURLOPT_FILE]);
|
291 |
}
|
292 |
+
$timeoutRequiresNoSignal = \false;
|
|
|
|
|
|
|
|
|
|
|
293 |
if (isset($options['timeout'])) {
|
294 |
$timeoutRequiresNoSignal |= $options['timeout'] < 1;
|
295 |
$conf[\CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
|
296 |
}
|
|
|
297 |
// CURL default value is CURL_IPRESOLVE_WHATEVER
|
298 |
if (isset($options['force_ip_resolve'])) {
|
299 |
if ('v4' === $options['force_ip_resolve']) {
|
302 |
$conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V6;
|
303 |
}
|
304 |
}
|
|
|
305 |
if (isset($options['connect_timeout'])) {
|
306 |
$timeoutRequiresNoSignal |= $options['connect_timeout'] < 1;
|
307 |
$conf[\CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
|
308 |
}
|
|
|
309 |
if ($timeoutRequiresNoSignal && \strtoupper(\substr(\PHP_OS, 0, 3)) !== 'WIN') {
|
310 |
+
$conf[\CURLOPT_NOSIGNAL] = \true;
|
311 |
}
|
|
|
312 |
if (isset($options['proxy'])) {
|
313 |
if (!\is_array($options['proxy'])) {
|
314 |
$conf[\CURLOPT_PROXY] = $options['proxy'];
|
316 |
$scheme = $easy->request->getUri()->getScheme();
|
317 |
if (isset($options['proxy'][$scheme])) {
|
318 |
$host = $easy->request->getUri()->getHost();
|
319 |
+
if (!isset($options['proxy']['no']) || !\PixelCaffeine\Dependencies\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])) {
|
320 |
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
321 |
}
|
322 |
}
|
323 |
}
|
324 |
}
|
|
|
325 |
if (isset($options['cert'])) {
|
326 |
$cert = $options['cert'];
|
327 |
if (\is_array($cert)) {
|
333 |
}
|
334 |
$conf[\CURLOPT_SSLCERT] = $cert;
|
335 |
}
|
|
|
336 |
if (isset($options['ssl_key'])) {
|
337 |
if (\is_array($options['ssl_key'])) {
|
338 |
if (\count($options['ssl_key']) === 2) {
|
339 |
+
list($sslKey, $conf[\CURLOPT_SSLKEYPASSWD]) = $options['ssl_key'];
|
340 |
} else {
|
341 |
+
list($sslKey) = $options['ssl_key'];
|
342 |
}
|
343 |
}
|
344 |
+
$sslKey = isset($sslKey) ? $sslKey : $options['ssl_key'];
|
|
|
|
|
345 |
if (!\file_exists($sslKey)) {
|
346 |
throw new \InvalidArgumentException("SSL private key not found: {$sslKey}");
|
347 |
}
|
348 |
$conf[\CURLOPT_SSLKEY] = $sslKey;
|
349 |
}
|
|
|
350 |
if (isset($options['progress'])) {
|
351 |
$progress = $options['progress'];
|
352 |
if (!\is_callable($progress)) {
|
353 |
throw new \InvalidArgumentException('progress client option must be callable');
|
354 |
}
|
355 |
+
$conf[\CURLOPT_NOPROGRESS] = \false;
|
356 |
+
$conf[\CURLOPT_PROGRESSFUNCTION] = function () use($progress) {
|
357 |
+
$args = \func_get_args();
|
358 |
+
// PHP 5.5 pushed the handle onto the start of the args
|
359 |
+
if (\is_resource($args[0])) {
|
360 |
+
\array_shift($args);
|
361 |
+
}
|
362 |
+
\call_user_func_array($progress, $args);
|
363 |
};
|
364 |
}
|
|
|
365 |
if (!empty($options['debug'])) {
|
366 |
+
$conf[\CURLOPT_STDERR] = \PixelCaffeine\Dependencies\GuzzleHttp\debug_resource($options['debug']);
|
367 |
+
$conf[\CURLOPT_VERBOSE] = \true;
|
368 |
}
|
369 |
}
|
|
|
370 |
/**
|
371 |
* This function ensures that a response was set on a transaction. If one
|
372 |
* was not set, then the request is retried if possible. This error
|
375 |
* stream, and then encountered a "necessary data rewind wasn't possible"
|
376 |
* error, causing the request to be sent through curl_multi_info_read()
|
377 |
* without an error status.
|
|
|
|
|
378 |
*/
|
379 |
+
private static function retryFailedRewind(callable $handler, \PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy, array $ctx)
|
380 |
{
|
381 |
try {
|
382 |
// Only rewind if the body has been read from.
|
385 |
$body->rewind();
|
386 |
}
|
387 |
} catch (\RuntimeException $e) {
|
388 |
+
$ctx['error'] = 'The connection unexpectedly failed without ' . 'providing an error. The request would have been retried, ' . 'but attempting to rewind the request body failed. ' . 'Exception: ' . $e;
|
|
|
|
|
|
|
389 |
return self::createRejection($easy, $ctx);
|
390 |
}
|
|
|
391 |
// Retry no more than 3 times before giving up.
|
392 |
if (!isset($easy->options['_curl_retries'])) {
|
393 |
$easy->options['_curl_retries'] = 1;
|
394 |
} elseif ($easy->options['_curl_retries'] == 2) {
|
395 |
+
$ctx['error'] = 'The cURL request was retried 3 times ' . 'and did not succeed. The most likely reason for the failure ' . 'is that cURL was unable to rewind the body of the request ' . 'and subsequent retries resulted in the same error. Turn on ' . 'the debug option to see what went wrong. See ' . 'https://bugs.php.net/bug.php?id=47204 for more information.';
|
|
|
|
|
|
|
|
|
|
|
396 |
return self::createRejection($easy, $ctx);
|
397 |
} else {
|
398 |
$easy->options['_curl_retries']++;
|
399 |
}
|
|
|
400 |
return $handler($easy->request, $easy->options);
|
401 |
}
|
402 |
+
private function createHeaderFn(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy)
|
|
|
403 |
{
|
404 |
if (isset($easy->options['on_headers'])) {
|
405 |
$onHeaders = $easy->options['on_headers'];
|
|
|
406 |
if (!\is_callable($onHeaders)) {
|
407 |
throw new \InvalidArgumentException('on_headers must be callable');
|
408 |
}
|
409 |
} else {
|
410 |
$onHeaders = null;
|
411 |
}
|
412 |
+
return function ($ch, $h) use($onHeaders, $easy, &$startingResponse) {
|
|
|
|
|
|
|
|
|
|
|
413 |
$value = \trim($h);
|
414 |
if ($value === '') {
|
415 |
+
$startingResponse = \true;
|
416 |
+
$easy->createResponse();
|
|
|
|
|
|
|
|
|
|
|
417 |
if ($onHeaders !== null) {
|
418 |
try {
|
419 |
$onHeaders($easy->response);
|
425 |
}
|
426 |
}
|
427 |
} elseif ($startingResponse) {
|
428 |
+
$startingResponse = \false;
|
429 |
$easy->headers = [$value];
|
430 |
} else {
|
431 |
$easy->headers[] = $value;
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Handler;
|
4 |
-
|
5 |
-
use Psr\Http\Message\RequestInterface;
|
6 |
|
|
|
7 |
interface CurlFactoryInterface
|
8 |
{
|
9 |
/**
|
@@ -12,14 +11,16 @@ interface CurlFactoryInterface
|
|
12 |
* @param RequestInterface $request Request
|
13 |
* @param array $options Transfer options
|
14 |
*
|
|
|
15 |
* @throws \RuntimeException when an option cannot be applied
|
16 |
*/
|
17 |
-
public function create(RequestInterface $request, array $options)
|
18 |
-
|
19 |
/**
|
20 |
* Release an easy handle, allowing it to be reused or closed.
|
21 |
*
|
22 |
* This function must call unset on the easy handle's "handle" property.
|
|
|
|
|
23 |
*/
|
24 |
-
public function release(EasyHandle $easy)
|
25 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
interface CurlFactoryInterface
|
7 |
{
|
8 |
/**
|
11 |
* @param RequestInterface $request Request
|
12 |
* @param array $options Transfer options
|
13 |
*
|
14 |
+
* @return EasyHandle
|
15 |
* @throws \RuntimeException when an option cannot be applied
|
16 |
*/
|
17 |
+
public function create(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options);
|
|
|
18 |
/**
|
19 |
* Release an easy handle, allowing it to be reused or closed.
|
20 |
*
|
21 |
* This function must call unset on the easy handle's "handle" property.
|
22 |
+
*
|
23 |
+
* @param EasyHandle $easy
|
24 |
*/
|
25 |
+
public function release(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\EasyHandle $easy);
|
26 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlHandler.php
RENAMED
@@ -1,26 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Handler;
|
4 |
-
|
5 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
6 |
-
use Psr\Http\Message\RequestInterface;
|
7 |
|
|
|
|
|
8 |
/**
|
9 |
* HTTP handler that uses cURL easy handles as a transport layer.
|
10 |
*
|
11 |
* When using the CurlHandler, custom curl options can be specified as an
|
12 |
* associative array of curl option constants mapping to values in the
|
13 |
* **curl** key of the "client" key of the request.
|
14 |
-
*
|
15 |
-
* @final
|
16 |
*/
|
17 |
class CurlHandler
|
18 |
{
|
19 |
-
/**
|
20 |
-
* @var CurlFactoryInterface
|
21 |
-
*/
|
22 |
private $factory;
|
23 |
-
|
24 |
/**
|
25 |
* Accepts an associative array of options:
|
26 |
*
|
@@ -30,20 +24,16 @@ class CurlHandler
|
|
30 |
*/
|
31 |
public function __construct(array $options = [])
|
32 |
{
|
33 |
-
$this->factory = $options['handle_factory']
|
34 |
-
?? new CurlFactory(3);
|
35 |
}
|
36 |
-
|
37 |
-
public function __invoke(RequestInterface $request, array $options): PromiseInterface
|
38 |
{
|
39 |
if (isset($options['delay'])) {
|
40 |
\usleep($options['delay'] * 1000);
|
41 |
}
|
42 |
-
|
43 |
$easy = $this->factory->create($request, $options);
|
44 |
\curl_exec($easy->handle);
|
45 |
$easy->errno = \curl_errno($easy->handle);
|
46 |
-
|
47 |
-
return CurlFactory::finish($this, $easy, $this->factory);
|
48 |
}
|
49 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
/**
|
8 |
* HTTP handler that uses cURL easy handles as a transport layer.
|
9 |
*
|
10 |
* When using the CurlHandler, custom curl options can be specified as an
|
11 |
* associative array of curl option constants mapping to values in the
|
12 |
* **curl** key of the "client" key of the request.
|
|
|
|
|
13 |
*/
|
14 |
class CurlHandler
|
15 |
{
|
16 |
+
/** @var CurlFactoryInterface */
|
|
|
|
|
17 |
private $factory;
|
|
|
18 |
/**
|
19 |
* Accepts an associative array of options:
|
20 |
*
|
24 |
*/
|
25 |
public function __construct(array $options = [])
|
26 |
{
|
27 |
+
$this->factory = isset($options['handle_factory']) ? $options['handle_factory'] : new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactory(3);
|
|
|
28 |
}
|
29 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
|
|
30 |
{
|
31 |
if (isset($options['delay'])) {
|
32 |
\usleep($options['delay'] * 1000);
|
33 |
}
|
|
|
34 |
$easy = $this->factory->create($request, $options);
|
35 |
\curl_exec($easy->handle);
|
36 |
$easy->errno = \curl_errno($easy->handle);
|
37 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactory::finish($this, $easy, $this->factory);
|
|
|
38 |
}
|
39 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php
RENAMED
@@ -1,13 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Handler;
|
4 |
-
|
5 |
-
use GuzzleHttp\Promise as P;
|
6 |
-
use GuzzleHttp\Promise\Promise;
|
7 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
8 |
-
use GuzzleHttp\Utils;
|
9 |
-
use Psr\Http\Message\RequestInterface;
|
10 |
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Returns an asynchronous response using curl_multi_* functions.
|
13 |
*
|
@@ -15,46 +13,17 @@ use Psr\Http\Message\RequestInterface;
|
|
15 |
* associative array of curl option constants mapping to values in the
|
16 |
* **curl** key of the provided request options.
|
17 |
*
|
18 |
-
* @property resource
|
19 |
-
*
|
20 |
-
* @final
|
21 |
*/
|
22 |
class CurlMultiHandler
|
23 |
{
|
24 |
-
/**
|
25 |
-
* @var CurlFactoryInterface
|
26 |
-
*/
|
27 |
private $factory;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var int
|
31 |
-
*/
|
32 |
private $selectTimeout;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @var resource|\CurlMultiHandle|null the currently executing resource in `curl_multi_exec`.
|
36 |
-
*/
|
37 |
private $active;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @var array Request entry handles, indexed by handle id in `addRequest`.
|
41 |
-
*
|
42 |
-
* @see CurlMultiHandler::addRequest
|
43 |
-
*/
|
44 |
private $handles = [];
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @var array<int, float> An array of delay times, indexed by handle id in `addRequest`.
|
48 |
-
*
|
49 |
-
* @see CurlMultiHandler::addRequest
|
50 |
-
*/
|
51 |
private $delays = [];
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var array<mixed> An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
|
55 |
-
*/
|
56 |
private $options = [];
|
57 |
-
|
58 |
/**
|
59 |
* This handler accepts the following options:
|
60 |
*
|
@@ -63,53 +32,35 @@ class CurlMultiHandler
|
|
63 |
* out while selecting curl handles. Defaults to 1 second.
|
64 |
* - options: An associative array of CURLMOPT_* options and
|
65 |
* corresponding values for curl_multi_setopt()
|
|
|
|
|
66 |
*/
|
67 |
public function __construct(array $options = [])
|
68 |
{
|
69 |
-
$this->factory = $options['handle_factory']
|
70 |
-
|
71 |
if (isset($options['select_timeout'])) {
|
72 |
$this->selectTimeout = $options['select_timeout'];
|
73 |
-
} elseif ($selectTimeout =
|
74 |
-
|
75 |
-
$this->selectTimeout = (int) $selectTimeout;
|
76 |
} else {
|
77 |
$this->selectTimeout = 1;
|
78 |
}
|
79 |
-
|
80 |
-
$this->options = $options['options'] ?? [];
|
81 |
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @param string $name
|
85 |
-
*
|
86 |
-
* @return resource|\CurlMultiHandle
|
87 |
-
*
|
88 |
-
* @throws \BadMethodCallException when another field as `_mh` will be gotten
|
89 |
-
* @throws \RuntimeException when curl can not initialize a multi handle
|
90 |
-
*/
|
91 |
public function __get($name)
|
92 |
{
|
93 |
-
if ($name
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$this->_mh = $multiHandle;
|
104 |
-
|
105 |
-
foreach ($this->options as $option => $value) {
|
106 |
-
// A warning is raised in case of a wrong option.
|
107 |
-
curl_multi_setopt($this->_mh, $option, $value);
|
108 |
}
|
109 |
-
|
110 |
-
return $this->_mh;
|
111 |
}
|
112 |
-
|
113 |
public function __destruct()
|
114 |
{
|
115 |
if (isset($this->_mh)) {
|
@@ -117,64 +68,48 @@ class CurlMultiHandler
|
|
117 |
unset($this->_mh);
|
118 |
}
|
119 |
}
|
120 |
-
|
121 |
-
public function __invoke(RequestInterface $request, array $options): PromiseInterface
|
122 |
{
|
123 |
$easy = $this->factory->create($request, $options);
|
124 |
$id = (int) $easy->handle;
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
function () use ($id) {
|
129 |
-
return $this->cancel($id);
|
130 |
-
}
|
131 |
-
);
|
132 |
-
|
133 |
$this->addRequest(['easy' => $easy, 'deferred' => $promise]);
|
134 |
-
|
135 |
return $promise;
|
136 |
}
|
137 |
-
|
138 |
/**
|
139 |
* Ticks the curl event loop.
|
140 |
*/
|
141 |
-
public function tick()
|
142 |
{
|
143 |
// Add any delayed handles if needed.
|
144 |
if ($this->delays) {
|
145 |
-
$currentTime = Utils::currentTime();
|
146 |
foreach ($this->delays as $id => $delay) {
|
147 |
if ($currentTime >= $delay) {
|
148 |
unset($this->delays[$id]);
|
149 |
-
\curl_multi_add_handle(
|
150 |
-
$this->_mh,
|
151 |
-
$this->handles[$id]['easy']->handle
|
152 |
-
);
|
153 |
}
|
154 |
}
|
155 |
}
|
156 |
-
|
157 |
// Step through the task queue which may add additional requests.
|
158 |
-
|
159 |
-
|
160 |
if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) {
|
161 |
// Perform a usleep if a select returns -1.
|
162 |
// See: https://bugs.php.net/bug.php?id=61141
|
163 |
\usleep(250);
|
164 |
}
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
$this->processMessages();
|
169 |
}
|
170 |
-
|
171 |
/**
|
172 |
* Runs until all outstanding connections have completed.
|
173 |
*/
|
174 |
-
public function execute()
|
175 |
{
|
176 |
-
$queue =
|
177 |
-
|
178 |
while ($this->handles || !$queue->isEmpty()) {
|
179 |
// If there are no transfers, then sleep for the next delay
|
180 |
if (!$this->active && $this->delays) {
|
@@ -183,8 +118,7 @@ class CurlMultiHandler
|
|
183 |
$this->tick();
|
184 |
}
|
185 |
}
|
186 |
-
|
187 |
-
private function addRequest(array $entry): void
|
188 |
{
|
189 |
$easy = $entry['easy'];
|
190 |
$id = (int) $easy->handle;
|
@@ -192,10 +126,9 @@ class CurlMultiHandler
|
|
192 |
if (empty($easy->options['delay'])) {
|
193 |
\curl_multi_add_handle($this->_mh, $easy->handle);
|
194 |
} else {
|
195 |
-
$this->delays[$id] = Utils::currentTime() +
|
196 |
}
|
197 |
}
|
198 |
-
|
199 |
/**
|
200 |
* Cancels a handle from sending and removes references to it.
|
201 |
*
|
@@ -203,51 +136,42 @@ class CurlMultiHandler
|
|
203 |
*
|
204 |
* @return bool True on success, false on failure.
|
205 |
*/
|
206 |
-
private function cancel($id)
|
207 |
{
|
208 |
// Cannot cancel if it has been processed.
|
209 |
if (!isset($this->handles[$id])) {
|
210 |
-
return false;
|
211 |
}
|
212 |
-
|
213 |
$handle = $this->handles[$id]['easy']->handle;
|
214 |
unset($this->delays[$id], $this->handles[$id]);
|
215 |
\curl_multi_remove_handle($this->_mh, $handle);
|
216 |
\curl_close($handle);
|
217 |
-
|
218 |
-
return true;
|
219 |
}
|
220 |
-
|
221 |
-
private function processMessages(): void
|
222 |
{
|
223 |
while ($done = \curl_multi_info_read($this->_mh)) {
|
224 |
$id = (int) $done['handle'];
|
225 |
\curl_multi_remove_handle($this->_mh, $done['handle']);
|
226 |
-
|
227 |
if (!isset($this->handles[$id])) {
|
228 |
// Probably was cancelled.
|
229 |
continue;
|
230 |
}
|
231 |
-
|
232 |
$entry = $this->handles[$id];
|
233 |
unset($this->handles[$id], $this->delays[$id]);
|
234 |
$entry['easy']->errno = $done['result'];
|
235 |
-
$entry['deferred']->resolve(
|
236 |
-
CurlFactory::finish($this, $entry['easy'], $this->factory)
|
237 |
-
);
|
238 |
}
|
239 |
}
|
240 |
-
|
241 |
-
private function timeToNext(): int
|
242 |
{
|
243 |
-
$currentTime = Utils::currentTime();
|
244 |
$nextTime = \PHP_INT_MAX;
|
245 |
foreach ($this->delays as $time) {
|
246 |
if ($time < $nextTime) {
|
247 |
$nextTime = $time;
|
248 |
}
|
249 |
}
|
250 |
-
|
251 |
-
return ((int) \max(0, $nextTime - $currentTime)) * 1000000;
|
252 |
}
|
253 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise as P;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Utils;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
9 |
/**
|
10 |
* Returns an asynchronous response using curl_multi_* functions.
|
11 |
*
|
13 |
* associative array of curl option constants mapping to values in the
|
14 |
* **curl** key of the provided request options.
|
15 |
*
|
16 |
+
* @property resource $_mh Internal use only. Lazy loaded multi-handle.
|
|
|
|
|
17 |
*/
|
18 |
class CurlMultiHandler
|
19 |
{
|
20 |
+
/** @var CurlFactoryInterface */
|
|
|
|
|
21 |
private $factory;
|
|
|
|
|
|
|
|
|
22 |
private $selectTimeout;
|
|
|
|
|
|
|
|
|
23 |
private $active;
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
private $handles = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
private $delays = [];
|
|
|
|
|
|
|
|
|
26 |
private $options = [];
|
|
|
27 |
/**
|
28 |
* This handler accepts the following options:
|
29 |
*
|
32 |
* out while selecting curl handles. Defaults to 1 second.
|
33 |
* - options: An associative array of CURLMOPT_* options and
|
34 |
* corresponding values for curl_multi_setopt()
|
35 |
+
*
|
36 |
+
* @param array $options
|
37 |
*/
|
38 |
public function __construct(array $options = [])
|
39 |
{
|
40 |
+
$this->factory = isset($options['handle_factory']) ? $options['handle_factory'] : new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactory(50);
|
|
|
41 |
if (isset($options['select_timeout'])) {
|
42 |
$this->selectTimeout = $options['select_timeout'];
|
43 |
+
} elseif ($selectTimeout = \getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
|
44 |
+
$this->selectTimeout = $selectTimeout;
|
|
|
45 |
} else {
|
46 |
$this->selectTimeout = 1;
|
47 |
}
|
48 |
+
$this->options = isset($options['options']) ? $options['options'] : [];
|
|
|
49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
public function __get($name)
|
51 |
{
|
52 |
+
if ($name === '_mh') {
|
53 |
+
$this->_mh = \curl_multi_init();
|
54 |
+
foreach ($this->options as $option => $value) {
|
55 |
+
// A warning is raised in case of a wrong option.
|
56 |
+
\curl_multi_setopt($this->_mh, $option, $value);
|
57 |
+
}
|
58 |
+
// Further calls to _mh will return the value directly, without entering the
|
59 |
+
// __get() method at all.
|
60 |
+
return $this->_mh;
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
+
throw new \BadMethodCallException();
|
|
|
63 |
}
|
|
|
64 |
public function __destruct()
|
65 |
{
|
66 |
if (isset($this->_mh)) {
|
68 |
unset($this->_mh);
|
69 |
}
|
70 |
}
|
71 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
|
|
72 |
{
|
73 |
$easy = $this->factory->create($request, $options);
|
74 |
$id = (int) $easy->handle;
|
75 |
+
$promise = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise([$this, 'execute'], function () use($id) {
|
76 |
+
return $this->cancel($id);
|
77 |
+
});
|
|
|
|
|
|
|
|
|
|
|
78 |
$this->addRequest(['easy' => $easy, 'deferred' => $promise]);
|
|
|
79 |
return $promise;
|
80 |
}
|
|
|
81 |
/**
|
82 |
* Ticks the curl event loop.
|
83 |
*/
|
84 |
+
public function tick()
|
85 |
{
|
86 |
// Add any delayed handles if needed.
|
87 |
if ($this->delays) {
|
88 |
+
$currentTime = \PixelCaffeine\Dependencies\GuzzleHttp\Utils::currentTime();
|
89 |
foreach ($this->delays as $id => $delay) {
|
90 |
if ($currentTime >= $delay) {
|
91 |
unset($this->delays[$id]);
|
92 |
+
\curl_multi_add_handle($this->_mh, $this->handles[$id]['easy']->handle);
|
|
|
|
|
|
|
93 |
}
|
94 |
}
|
95 |
}
|
|
|
96 |
// Step through the task queue which may add additional requests.
|
97 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Promise\queue()->run();
|
|
|
98 |
if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) {
|
99 |
// Perform a usleep if a select returns -1.
|
100 |
// See: https://bugs.php.net/bug.php?id=61141
|
101 |
\usleep(250);
|
102 |
}
|
103 |
+
while (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM) {
|
104 |
+
}
|
|
|
105 |
$this->processMessages();
|
106 |
}
|
|
|
107 |
/**
|
108 |
* Runs until all outstanding connections have completed.
|
109 |
*/
|
110 |
+
public function execute()
|
111 |
{
|
112 |
+
$queue = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\queue();
|
|
|
113 |
while ($this->handles || !$queue->isEmpty()) {
|
114 |
// If there are no transfers, then sleep for the next delay
|
115 |
if (!$this->active && $this->delays) {
|
118 |
$this->tick();
|
119 |
}
|
120 |
}
|
121 |
+
private function addRequest(array $entry)
|
|
|
122 |
{
|
123 |
$easy = $entry['easy'];
|
124 |
$id = (int) $easy->handle;
|
126 |
if (empty($easy->options['delay'])) {
|
127 |
\curl_multi_add_handle($this->_mh, $easy->handle);
|
128 |
} else {
|
129 |
+
$this->delays[$id] = \PixelCaffeine\Dependencies\GuzzleHttp\Utils::currentTime() + $easy->options['delay'] / 1000;
|
130 |
}
|
131 |
}
|
|
|
132 |
/**
|
133 |
* Cancels a handle from sending and removes references to it.
|
134 |
*
|
136 |
*
|
137 |
* @return bool True on success, false on failure.
|
138 |
*/
|
139 |
+
private function cancel($id)
|
140 |
{
|
141 |
// Cannot cancel if it has been processed.
|
142 |
if (!isset($this->handles[$id])) {
|
143 |
+
return \false;
|
144 |
}
|
|
|
145 |
$handle = $this->handles[$id]['easy']->handle;
|
146 |
unset($this->delays[$id], $this->handles[$id]);
|
147 |
\curl_multi_remove_handle($this->_mh, $handle);
|
148 |
\curl_close($handle);
|
149 |
+
return \true;
|
|
|
150 |
}
|
151 |
+
private function processMessages()
|
|
|
152 |
{
|
153 |
while ($done = \curl_multi_info_read($this->_mh)) {
|
154 |
$id = (int) $done['handle'];
|
155 |
\curl_multi_remove_handle($this->_mh, $done['handle']);
|
|
|
156 |
if (!isset($this->handles[$id])) {
|
157 |
// Probably was cancelled.
|
158 |
continue;
|
159 |
}
|
|
|
160 |
$entry = $this->handles[$id];
|
161 |
unset($this->handles[$id], $this->delays[$id]);
|
162 |
$entry['easy']->errno = $done['result'];
|
163 |
+
$entry['deferred']->resolve(\PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlFactory::finish($this, $entry['easy'], $this->factory));
|
|
|
|
|
164 |
}
|
165 |
}
|
166 |
+
private function timeToNext()
|
|
|
167 |
{
|
168 |
+
$currentTime = \PixelCaffeine\Dependencies\GuzzleHttp\Utils::currentTime();
|
169 |
$nextTime = \PHP_INT_MAX;
|
170 |
foreach ($this->delays as $time) {
|
171 |
if ($time < $nextTime) {
|
172 |
$nextTime = $time;
|
173 |
}
|
174 |
}
|
175 |
+
return \max(0, $nextTime - $currentTime) * 1000000;
|
|
|
176 |
}
|
177 |
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Handler/EasyHandle.php
RENAMED
@@ -1,13 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Handler;
|
4 |
-
|
5 |
-
use GuzzleHttp\Psr7\Response;
|
6 |
-
use GuzzleHttp\Utils;
|
7 |
-
use Psr\Http\Message\RequestInterface;
|
8 |
-
use Psr\Http\Message\ResponseInterface;
|
9 |
-
use Psr\Http\Message\StreamInterface;
|
10 |
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Represents a cURL easy handle and the data it populates.
|
13 |
*
|
@@ -15,73 +13,41 @@ use Psr\Http\Message\StreamInterface;
|
|
15 |
*/
|
16 |
final class EasyHandle
|
17 |
{
|
18 |
-
/**
|
19 |
-
* @var resource|\CurlHandle cURL resource
|
20 |
-
*/
|
21 |
public $handle;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var StreamInterface Where data is being written
|
25 |
-
*/
|
26 |
public $sink;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var array Received HTTP headers so far
|
30 |
-
*/
|
31 |
public $headers = [];
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var ResponseInterface|null Received response (if any)
|
35 |
-
*/
|
36 |
public $response;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var RequestInterface Request being sent
|
40 |
-
*/
|
41 |
public $request;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var array Request options
|
45 |
-
*/
|
46 |
public $options = [];
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var int cURL error number (if any)
|
50 |
-
*/
|
51 |
public $errno = 0;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var \Throwable|null Exception during on_headers (if any)
|
55 |
-
*/
|
56 |
public $onHeadersException;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @var \Exception|null Exception during createResponse (if any)
|
60 |
-
*/
|
61 |
-
public $createResponseException;
|
62 |
-
|
63 |
/**
|
64 |
* Attach a response to the easy handle based on the received headers.
|
65 |
*
|
66 |
* @throws \RuntimeException if no headers have been received.
|
67 |
*/
|
68 |
-
public function createResponse()
|
69 |
{
|
70 |
if (empty($this->headers)) {
|
71 |
throw new \RuntimeException('No headers have been received');
|
72 |
}
|
73 |
-
|
74 |
// HTTP-version SP status-code SP reason-phrase
|
75 |
$startLine = \explode(' ', \array_shift($this->headers), 3);
|
76 |
-
$headers =
|
77 |
-
$normalizedKeys =
|
78 |
-
|
79 |
if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
|
80 |
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
|
81 |
unset($headers[$normalizedKeys['content-encoding']]);
|
82 |
if (isset($normalizedKeys['content-length'])) {
|
83 |
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
|
84 |
-
|
85 |
$bodyLength = (int) $this->sink->getSize();
|
86 |
if ($bodyLength) {
|
87 |
$headers[$normalizedKeys['content-length']] = $bodyLength;
|
@@ -90,26 +56,9 @@ final class EasyHandle
|
|
90 |
}
|
91 |
}
|
92 |
}
|
93 |
-
|
94 |
-
$statusCode = (int) $startLine[1];
|
95 |
-
|
96 |
// Attach a response to the easy handle with the parsed headers.
|
97 |
-
$this->response = new Response(
|
98 |
-
$statusCode,
|
99 |
-
$headers,
|
100 |
-
$this->sink,
|
101 |
-
\substr($startLine[0], 5),
|
102 |
-
isset($startLine[2]) ? (string) $startLine[2] : null
|
103 |
-
);
|
104 |
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* @param string $name
|
108 |
-
*
|
109 |
-
* @return void
|
110 |
-
*
|
111 |
-
* @throws \BadMethodCallException
|
112 |
-
*/
|
113 |
public function __get($name)
|
114 |
{
|
115 |
$msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Response;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
9 |
/**
|
10 |
* Represents a cURL easy handle and the data it populates.
|
11 |
*
|
13 |
*/
|
14 |
final class EasyHandle
|
15 |
{
|
16 |
+
/** @var resource cURL resource */
|
|
|
|
|
17 |
public $handle;
|
18 |
+
/** @var StreamInterface Where data is being written */
|
|
|
|
|
|
|
19 |
public $sink;
|
20 |
+
/** @var array Received HTTP headers so far */
|
|
|
|
|
|
|
21 |
public $headers = [];
|
22 |
+
/** @var ResponseInterface Received response (if any) */
|
|
|
|
|
|
|
23 |
public $response;
|
24 |
+
/** @var RequestInterface Request being sent */
|
|
|
|
|
|
|
25 |
public $request;
|
26 |
+
/** @var array Request options */
|
|
|
|
|
|
|
27 |
public $options = [];
|
28 |
+
/** @var int cURL error number (if any) */
|
|
|
|
|
|
|
29 |
public $errno = 0;
|
30 |
+
/** @var \Exception Exception during on_headers (if any) */
|
|
|
|
|
|
|
31 |
public $onHeadersException;
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* Attach a response to the easy handle based on the received headers.
|
34 |
*
|
35 |
* @throws \RuntimeException if no headers have been received.
|
36 |
*/
|
37 |
+
public function createResponse()
|
38 |
{
|
39 |
if (empty($this->headers)) {
|
40 |
throw new \RuntimeException('No headers have been received');
|
41 |
}
|
|
|
42 |
// HTTP-version SP status-code SP reason-phrase
|
43 |
$startLine = \explode(' ', \array_shift($this->headers), 3);
|
44 |
+
$headers = \PixelCaffeine\Dependencies\GuzzleHttp\headers_from_lines($this->headers);
|
45 |
+
$normalizedKeys = \PixelCaffeine\Dependencies\GuzzleHttp\normalize_header_keys($headers);
|
|
|
46 |
if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
|
47 |
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
|
48 |
unset($headers[$normalizedKeys['content-encoding']]);
|
49 |
if (isset($normalizedKeys['content-length'])) {
|
50 |
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
|
|
|
51 |
$bodyLength = (int) $this->sink->getSize();
|
52 |
if ($bodyLength) {
|
53 |
$headers[$normalizedKeys['content-length']] = $bodyLength;
|
56 |
}
|
57 |
}
|
58 |
}
|
|
|
|
|
|
|
59 |
// Attach a response to the easy handle with the parsed headers.
|
60 |
+
$this->response = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Response($startLine[1], $headers, $this->sink, \substr($startLine[0], 5), isset($startLine[2]) ? (string) $startLine[2] : null);
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
public function __get($name)
|
63 |
{
|
64 |
$msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
|
third-party/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\HandlerStack;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectedPromise;
|
9 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\TransferStats;
|
10 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
11 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
12 |
+
/**
|
13 |
+
* Handler that returns responses or throw exceptions from a queue.
|
14 |
+
*/
|
15 |
+
class MockHandler implements \Countable
|
16 |
+
{
|
17 |
+
private $queue = [];
|
18 |
+
private $lastRequest;
|
19 |
+
private $lastOptions;
|
20 |
+
private $onFulfilled;
|
21 |
+
private $onRejected;
|
22 |
+
/**
|
23 |
+
* Creates a new MockHandler that uses the default handler stack list of
|
24 |
+
* middlewares.
|
25 |
+
*
|
26 |
+
* @param array $queue Array of responses, callables, or exceptions.
|
27 |
+
* @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
|
28 |
+
* @param callable $onRejected Callback to invoke when the return value is rejected.
|
29 |
+
*
|
30 |
+
* @return HandlerStack
|
31 |
+
*/
|
32 |
+
public static function createWithMiddleware(array $queue = null, callable $onFulfilled = null, callable $onRejected = null)
|
33 |
+
{
|
34 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* The passed in value must be an array of
|
38 |
+
* {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions,
|
39 |
+
* callables, or Promises.
|
40 |
+
*
|
41 |
+
* @param array $queue
|
42 |
+
* @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
|
43 |
+
* @param callable $onRejected Callback to invoke when the return value is rejected.
|
44 |
+
*/
|
45 |
+
public function __construct(array $queue = null, callable $onFulfilled = null, callable $onRejected = null)
|
46 |
+
{
|
47 |
+
$this->onFulfilled = $onFulfilled;
|
48 |
+
$this->onRejected = $onRejected;
|
49 |
+
if ($queue) {
|
50 |
+
\call_user_func_array([$this, 'append'], $queue);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
54 |
+
{
|
55 |
+
if (!$this->queue) {
|
56 |
+
throw new \OutOfBoundsException('Mock queue is empty');
|
57 |
+
}
|
58 |
+
if (isset($options['delay']) && \is_numeric($options['delay'])) {
|
59 |
+
\usleep($options['delay'] * 1000);
|
60 |
+
}
|
61 |
+
$this->lastRequest = $request;
|
62 |
+
$this->lastOptions = $options;
|
63 |
+
$response = \array_shift($this->queue);
|
64 |
+
if (isset($options['on_headers'])) {
|
65 |
+
if (!\is_callable($options['on_headers'])) {
|
66 |
+
throw new \InvalidArgumentException('on_headers must be callable');
|
67 |
+
}
|
68 |
+
try {
|
69 |
+
$options['on_headers']($response);
|
70 |
+
} catch (\Exception $e) {
|
71 |
+
$msg = 'An error was encountered during the on_headers event';
|
72 |
+
$response = new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException($msg, $request, $response, $e);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
if (\is_callable($response)) {
|
76 |
+
$response = \call_user_func($response, $request, $options);
|
77 |
+
}
|
78 |
+
$response = $response instanceof \Exception ? \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($response) : \PixelCaffeine\Dependencies\GuzzleHttp\Promise\promise_for($response);
|
79 |
+
return $response->then(function ($value) use($request, $options) {
|
80 |
+
$this->invokeStats($request, $options, $value);
|
81 |
+
if ($this->onFulfilled) {
|
82 |
+
\call_user_func($this->onFulfilled, $value);
|
83 |
+
}
|
84 |
+
if (isset($options['sink'])) {
|
85 |
+
$contents = (string) $value->getBody();
|
86 |
+
$sink = $options['sink'];
|
87 |
+
if (\is_resource($sink)) {
|
88 |
+
\fwrite($sink, $contents);
|
89 |
+
} elseif (\is_string($sink)) {
|
90 |
+
\file_put_contents($sink, $contents);
|
91 |
+
} elseif ($sink instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface) {
|
92 |
+
$sink->write($contents);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
return $value;
|
96 |
+
}, function ($reason) use($request, $options) {
|
97 |
+
$this->invokeStats($request, $options, null, $reason);
|
98 |
+
if ($this->onRejected) {
|
99 |
+
\call_user_func($this->onRejected, $reason);
|
100 |
+
}
|
101 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($reason);
|
102 |
+
});
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Adds one or more variadic requests, exceptions, callables, or promises
|
106 |
+
* to the queue.
|
107 |
+
*/
|
108 |
+
public function append()
|
109 |
+
{
|
110 |
+
foreach (\func_get_args() as $value) {
|
111 |
+
if ($value instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface || $value instanceof \Exception || $value instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface || \is_callable($value)) {
|
112 |
+
$this->queue[] = $value;
|
113 |
+
} else {
|
114 |
+
throw new \InvalidArgumentException('Expected a response or ' . 'exception. Found ' . \PixelCaffeine\Dependencies\GuzzleHttp\describe_type($value));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* Get the last received request.
|
120 |
+
*
|
121 |
+
* @return RequestInterface
|
122 |
+
*/
|
123 |
+
public function getLastRequest()
|
124 |
+
{
|
125 |
+
return $this->lastRequest;
|
126 |
+
}
|
127 |
+
/**
|
128 |
+
* Get the last received request options.
|
129 |
+
*
|
130 |
+
* @return array
|
131 |
+
*/
|
132 |
+
public function getLastOptions()
|
133 |
+
{
|
134 |
+
return $this->lastOptions;
|
135 |
+
}
|
136 |
+
/**
|
137 |
+
* Returns the number of remaining items in the queue.
|
138 |
+
*
|
139 |
+
* @return int
|
140 |
+
*/
|
141 |
+
public function count()
|
142 |
+
{
|
143 |
+
return \count($this->queue);
|
144 |
+
}
|
145 |
+
public function reset()
|
146 |
+
{
|
147 |
+
$this->queue = [];
|
148 |
+
}
|
149 |
+
private function invokeStats(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, $reason = null)
|
150 |
+
{
|
151 |
+
if (isset($options['on_stats'])) {
|
152 |
+
$transferTime = isset($options['transfer_time']) ? $options['transfer_time'] : 0;
|
153 |
+
$stats = new \PixelCaffeine\Dependencies\GuzzleHttp\TransferStats($request, $response, $transferTime, $reason);
|
154 |
+
\call_user_func($options['on_stats'], $stats);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\RequestOptions;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
/**
|
8 |
+
* Provides basic proxies for handlers.
|
9 |
+
*/
|
10 |
+
class Proxy
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Sends synchronous requests to a specific handler while sending all other
|
14 |
+
* requests to another handler.
|
15 |
+
*
|
16 |
+
* @param callable $default Handler used for normal responses
|
17 |
+
* @param callable $sync Handler used for synchronous responses.
|
18 |
+
*
|
19 |
+
* @return callable Returns the composed handler.
|
20 |
+
*/
|
21 |
+
public static function wrapSync(callable $default, callable $sync)
|
22 |
+
{
|
23 |
+
return function (\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options) use($default, $sync) {
|
24 |
+
return empty($options[\PixelCaffeine\Dependencies\GuzzleHttp\RequestOptions::SYNCHRONOUS]) ? $default($request, $options) : $sync($request, $options);
|
25 |
+
};
|
26 |
+
}
|
27 |
+
/**
|
28 |
+
* Sends streaming requests to a streaming compatible handler while sending
|
29 |
+
* all other requests to a default handler.
|
30 |
+
*
|
31 |
+
* This, for example, could be useful for taking advantage of the
|
32 |
+
* performance benefits of curl while still supporting true streaming
|
33 |
+
* through the StreamHandler.
|
34 |
+
*
|
35 |
+
* @param callable $default Handler used for non-streaming responses
|
36 |
+
* @param callable $streaming Handler used for streaming responses
|
37 |
+
*
|
38 |
+
* @return callable Returns the composed handler.
|
39 |
+
*/
|
40 |
+
public static function wrapStreaming(callable $default, callable $streaming)
|
41 |
+
{
|
42 |
+
return function (\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options) use($default, $streaming) {
|
43 |
+
return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options);
|
44 |
+
};
|
45 |
+
}
|
46 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
ADDED
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Handler;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\FulfilledPromise;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
9 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
10 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\TransferStats;
|
11 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Utils;
|
12 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
13 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
14 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
15 |
+
/**
|
16 |
+
* HTTP handler that uses PHP's HTTP stream wrapper.
|
17 |
+
*/
|
18 |
+
class StreamHandler
|
19 |
+
{
|
20 |
+
private $lastHeaders = [];
|
21 |
+
/**
|
22 |
+
* Sends an HTTP request.
|
23 |
+
*
|
24 |
+
* @param RequestInterface $request Request to send.
|
25 |
+
* @param array $options Request transfer options.
|
26 |
+
*
|
27 |
+
* @return PromiseInterface
|
28 |
+
*/
|
29 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
30 |
+
{
|
31 |
+
// Sleep if there is a delay specified.
|
32 |
+
if (isset($options['delay'])) {
|
33 |
+
\usleep($options['delay'] * 1000);
|
34 |
+
}
|
35 |
+
$startTime = isset($options['on_stats']) ? \PixelCaffeine\Dependencies\GuzzleHttp\Utils::currentTime() : null;
|
36 |
+
try {
|
37 |
+
// Does not support the expect header.
|
38 |
+
$request = $request->withoutHeader('Expect');
|
39 |
+
// Append a content-length header if body size is zero to match
|
40 |
+
// cURL's behavior.
|
41 |
+
if (0 === $request->getBody()->getSize()) {
|
42 |
+
$request = $request->withHeader('Content-Length', '0');
|
43 |
+
}
|
44 |
+
return $this->createResponse($request, $options, $this->createStream($request, $options), $startTime);
|
45 |
+
} catch (\InvalidArgumentException $e) {
|
46 |
+
throw $e;
|
47 |
+
} catch (\Exception $e) {
|
48 |
+
// Determine if the error was a networking error.
|
49 |
+
$message = $e->getMessage();
|
50 |
+
// This list can probably get more comprehensive.
|
51 |
+
if (\strpos($message, 'getaddrinfo') || \strpos($message, 'Connection refused') || \strpos($message, "couldn't connect to host") || \strpos($message, "connection attempt failed")) {
|
52 |
+
$e = new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException($e->getMessage(), $request, $e);
|
53 |
+
}
|
54 |
+
$e = \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException::wrapException($request, $e);
|
55 |
+
$this->invokeStats($options, $request, $startTime, null, $e);
|
56 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($e);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
private function invokeStats(array $options, \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, $startTime, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, $error = null)
|
60 |
+
{
|
61 |
+
if (isset($options['on_stats'])) {
|
62 |
+
$stats = new \PixelCaffeine\Dependencies\GuzzleHttp\TransferStats($request, $response, \PixelCaffeine\Dependencies\GuzzleHttp\Utils::currentTime() - $startTime, $error, []);
|
63 |
+
\call_user_func($options['on_stats'], $stats);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
private function createResponse(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, $stream, $startTime)
|
67 |
+
{
|
68 |
+
$hdrs = $this->lastHeaders;
|
69 |
+
$this->lastHeaders = [];
|
70 |
+
$parts = \explode(' ', \array_shift($hdrs), 3);
|
71 |
+
$ver = \explode('/', $parts[0])[1];
|
72 |
+
$status = $parts[1];
|
73 |
+
$reason = isset($parts[2]) ? $parts[2] : null;
|
74 |
+
$headers = \PixelCaffeine\Dependencies\GuzzleHttp\headers_from_lines($hdrs);
|
75 |
+
list($stream, $headers) = $this->checkDecode($options, $headers, $stream);
|
76 |
+
$stream = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($stream);
|
77 |
+
$sink = $stream;
|
78 |
+
if (\strcasecmp('HEAD', $request->getMethod())) {
|
79 |
+
$sink = $this->createSink($stream, $options);
|
80 |
+
}
|
81 |
+
$response = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Response($status, $headers, $sink, $ver, $reason);
|
82 |
+
if (isset($options['on_headers'])) {
|
83 |
+
try {
|
84 |
+
$options['on_headers']($response);
|
85 |
+
} catch (\Exception $e) {
|
86 |
+
$msg = 'An error was encountered during the on_headers event';
|
87 |
+
$ex = new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException($msg, $request, $response, $e);
|
88 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($ex);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
// Do not drain when the request is a HEAD request because they have
|
92 |
+
// no body.
|
93 |
+
if ($sink !== $stream) {
|
94 |
+
$this->drain($stream, $sink, $response->getHeaderLine('Content-Length'));
|
95 |
+
}
|
96 |
+
$this->invokeStats($options, $request, $startTime, $response, null);
|
97 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\FulfilledPromise($response);
|
98 |
+
}
|
99 |
+
private function createSink(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, array $options)
|
100 |
+
{
|
101 |
+
if (!empty($options['stream'])) {
|
102 |
+
return $stream;
|
103 |
+
}
|
104 |
+
$sink = isset($options['sink']) ? $options['sink'] : \fopen('php://temp', 'r+');
|
105 |
+
return \is_string($sink) ? new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream($sink, 'w+') : \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($sink);
|
106 |
+
}
|
107 |
+
private function checkDecode(array $options, array $headers, $stream)
|
108 |
+
{
|
109 |
+
// Automatically decode responses when instructed.
|
110 |
+
if (!empty($options['decode_content'])) {
|
111 |
+
$normalizedKeys = \PixelCaffeine\Dependencies\GuzzleHttp\normalize_header_keys($headers);
|
112 |
+
if (isset($normalizedKeys['content-encoding'])) {
|
113 |
+
$encoding = $headers[$normalizedKeys['content-encoding']];
|
114 |
+
if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
|
115 |
+
$stream = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\InflateStream(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\stream_for($stream));
|
116 |
+
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
|
117 |
+
// Remove content-encoding header
|
118 |
+
unset($headers[$normalizedKeys['content-encoding']]);
|
119 |
+
// Fix content-length header
|
120 |
+
if (isset($normalizedKeys['content-length'])) {
|
121 |
+
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
|
122 |
+
$length = (int) $stream->getSize();
|
123 |
+
if ($length === 0) {
|
124 |
+
unset($headers[$normalizedKeys['content-length']]);
|
125 |
+
} else {
|
126 |
+
$headers[$normalizedKeys['content-length']] = [$length];
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
return [$stream, $headers];
|
133 |
+
}
|
134 |
+
/**
|
135 |
+
* Drains the source stream into the "sink" client option.
|
136 |
+
*
|
137 |
+
* @param StreamInterface $source
|
138 |
+
* @param StreamInterface $sink
|
139 |
+
* @param string $contentLength Header specifying the amount of
|
140 |
+
* data to read.
|
141 |
+
*
|
142 |
+
* @return StreamInterface
|
143 |
+
* @throws \RuntimeException when the sink option is invalid.
|
144 |
+
*/
|
145 |
+
private function drain(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $source, \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $sink, $contentLength)
|
146 |
+
{
|
147 |
+
// If a content-length header is provided, then stop reading once
|
148 |
+
// that number of bytes has been read. This can prevent infinitely
|
149 |
+
// reading from a stream when dealing with servers that do not honor
|
150 |
+
// Connection: Close headers.
|
151 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\copy_to_stream($source, $sink, \strlen($contentLength) > 0 && (int) $contentLength > 0 ? (int) $contentLength : -1);
|
152 |
+
$sink->seek(0);
|
153 |
+
$source->close();
|
154 |
+
return $sink;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* Create a resource and check to ensure it was created successfully
|
158 |
+
*
|
159 |
+
* @param callable $callback Callable that returns stream resource
|
160 |
+
*
|
161 |
+
* @return resource
|
162 |
+
* @throws \RuntimeException on error
|
163 |
+
*/
|
164 |
+
private function createResource(callable $callback)
|
165 |
+
{
|
166 |
+
$errors = null;
|
167 |
+
\set_error_handler(function ($_, $msg, $file, $line) use(&$errors) {
|
168 |
+
$errors[] = ['message' => $msg, 'file' => $file, 'line' => $line];
|
169 |
+
return \true;
|
170 |
+
});
|
171 |
+
$resource = $callback();
|
172 |
+
\restore_error_handler();
|
173 |
+
if (!$resource) {
|
174 |
+
$message = 'Error creating resource: ';
|
175 |
+
foreach ($errors as $err) {
|
176 |
+
foreach ($err as $key => $value) {
|
177 |
+
$message .= "[{$key}] {$value}" . \PHP_EOL;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
throw new \RuntimeException(\trim($message));
|
181 |
+
}
|
182 |
+
return $resource;
|
183 |
+
}
|
184 |
+
private function createStream(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
185 |
+
{
|
186 |
+
static $methods;
|
187 |
+
if (!$methods) {
|
188 |
+
$methods = \array_flip(\get_class_methods(__CLASS__));
|
189 |
+
}
|
190 |
+
// HTTP/1.1 streams using the PHP stream wrapper require a
|
191 |
+
// Connection: close header
|
192 |
+
if ($request->getProtocolVersion() == '1.1' && !$request->hasHeader('Connection')) {
|
193 |
+
$request = $request->withHeader('Connection', 'close');
|
194 |
+
}
|
195 |
+
// Ensure SSL is verified by default
|
196 |
+
if (!isset($options['verify'])) {
|
197 |
+
$options['verify'] = \true;
|
198 |
+
}
|
199 |
+
$params = [];
|
200 |
+
$context = $this->getDefaultContext($request);
|
201 |
+
if (isset($options['on_headers']) && !\is_callable($options['on_headers'])) {
|
202 |
+
throw new \InvalidArgumentException('on_headers must be callable');
|
203 |
+
}
|
204 |
+
if (!empty($options)) {
|
205 |
+
foreach ($options as $key => $value) {
|
206 |
+
$method = "add_{$key}";
|
207 |
+
if (isset($methods[$method])) {
|
208 |
+
$this->{$method}($request, $context, $value, $params);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
if (isset($options['stream_context'])) {
|
213 |
+
if (!\is_array($options['stream_context'])) {
|
214 |
+
throw new \InvalidArgumentException('stream_context must be an array');
|
215 |
+
}
|
216 |
+
$context = \array_replace_recursive($context, $options['stream_context']);
|
217 |
+
}
|
218 |
+
// Microsoft NTLM authentication only supported with curl handler
|
219 |
+
if (isset($options['auth']) && \is_array($options['auth']) && isset($options['auth'][2]) && 'ntlm' == $options['auth'][2]) {
|
220 |
+
throw new \InvalidArgumentException('Microsoft NTLM authentication only supported with curl handler');
|
221 |
+
}
|
222 |
+
$uri = $this->resolveHost($request, $options);
|
223 |
+
$context = $this->createResource(function () use($context, $params) {
|
224 |
+
return \stream_context_create($context, $params);
|
225 |
+
});
|
226 |
+
return $this->createResource(function () use($uri, &$http_response_header, $context, $options) {
|
227 |
+
$resource = \fopen((string) $uri, 'r', null, $context);
|
228 |
+
$this->lastHeaders = $http_response_header;
|
229 |
+
if (isset($options['read_timeout'])) {
|
230 |
+
$readTimeout = $options['read_timeout'];
|
231 |
+
$sec = (int) $readTimeout;
|
232 |
+
$usec = ($readTimeout - $sec) * 100000;
|
233 |
+
\stream_set_timeout($resource, $sec, $usec);
|
234 |
+
}
|
235 |
+
return $resource;
|
236 |
+
});
|
237 |
+
}
|
238 |
+
private function resolveHost(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
239 |
+
{
|
240 |
+
$uri = $request->getUri();
|
241 |
+
if (isset($options['force_ip_resolve']) && !\filter_var($uri->getHost(), \FILTER_VALIDATE_IP)) {
|
242 |
+
if ('v4' === $options['force_ip_resolve']) {
|
243 |
+
$records = \dns_get_record($uri->getHost(), \DNS_A);
|
244 |
+
if (!isset($records[0]['ip'])) {
|
245 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException(\sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request);
|
246 |
+
}
|
247 |
+
$uri = $uri->withHost($records[0]['ip']);
|
248 |
+
} elseif ('v6' === $options['force_ip_resolve']) {
|
249 |
+
$records = \dns_get_record($uri->getHost(), \DNS_AAAA);
|
250 |
+
if (!isset($records[0]['ipv6'])) {
|
251 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\ConnectException(\sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request);
|
252 |
+
}
|
253 |
+
$uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
|
254 |
+
}
|
255 |
+
}
|
256 |
+
return $uri;
|
257 |
+
}
|
258 |
+
private function getDefaultContext(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request)
|
259 |
+
{
|
260 |
+
$headers = '';
|
261 |
+
foreach ($request->getHeaders() as $name => $value) {
|
262 |
+
foreach ($value as $val) {
|
263 |
+
$headers .= "{$name}: {$val}\r\n";
|
264 |
+
}
|
265 |
+
}
|
266 |
+
$context = ['http' => ['method' => $request->getMethod(), 'header' => $headers, 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => \true, 'follow_location' => 0]];
|
267 |
+
$body = (string) $request->getBody();
|
268 |
+
if (!empty($body)) {
|
269 |
+
$context['http']['content'] = $body;
|
270 |
+
// Prevent the HTTP handler from adding a Content-Type header.
|
271 |
+
if (!$request->hasHeader('Content-Type')) {
|
272 |
+
$context['http']['header'] .= "Content-Type:\r\n";
|
273 |
+
}
|
274 |
+
}
|
275 |
+
$context['http']['header'] = \rtrim($context['http']['header']);
|
276 |
+
return $context;
|
277 |
+
}
|
278 |
+
private function add_proxy(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
279 |
+
{
|
280 |
+
if (!\is_array($value)) {
|
281 |
+
$options['http']['proxy'] = $value;
|
282 |
+
} else {
|
283 |
+
$scheme = $request->getUri()->getScheme();
|
284 |
+
if (isset($value[$scheme])) {
|
285 |
+
if (!isset($value['no']) || !\PixelCaffeine\Dependencies\GuzzleHttp\is_host_in_noproxy($request->getUri()->getHost(), $value['no'])) {
|
286 |
+
$options['http']['proxy'] = $value[$scheme];
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
private function add_timeout(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
292 |
+
{
|
293 |
+
if ($value > 0) {
|
294 |
+
$options['http']['timeout'] = $value;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
private function add_verify(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
298 |
+
{
|
299 |
+
if ($value === \true) {
|
300 |
+
// PHP 5.6 or greater will find the system cert by default. When
|
301 |
+
// < 5.6, use the Guzzle bundled cacert.
|
302 |
+
if (\PHP_VERSION_ID < 50600) {
|
303 |
+
$options['ssl']['cafile'] = \PixelCaffeine\Dependencies\GuzzleHttp\default_ca_bundle();
|
304 |
+
}
|
305 |
+
} elseif (\is_string($value)) {
|
306 |
+
$options['ssl']['cafile'] = $value;
|
307 |
+
if (!\file_exists($value)) {
|
308 |
+
throw new \RuntimeException("SSL CA bundle not found: {$value}");
|
309 |
+
}
|
310 |
+
} elseif ($value === \false) {
|
311 |
+
$options['ssl']['verify_peer'] = \false;
|
312 |
+
$options['ssl']['verify_peer_name'] = \false;
|
313 |
+
return;
|
314 |
+
} else {
|
315 |
+
throw new \InvalidArgumentException('Invalid verify request option');
|
316 |
+
}
|
317 |
+
$options['ssl']['verify_peer'] = \true;
|
318 |
+
$options['ssl']['verify_peer_name'] = \true;
|
319 |
+
$options['ssl']['allow_self_signed'] = \false;
|
320 |
+
}
|
321 |
+
private function add_cert(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
322 |
+
{
|
323 |
+
if (\is_array($value)) {
|
324 |
+
$options['ssl']['passphrase'] = $value[1];
|
325 |
+
$value = $value[0];
|
326 |
+
}
|
327 |
+
if (!\file_exists($value)) {
|
328 |
+
throw new \RuntimeException("SSL certificate not found: {$value}");
|
329 |
+
}
|
330 |
+
$options['ssl']['local_cert'] = $value;
|
331 |
+
}
|
332 |
+
private function add_progress(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
333 |
+
{
|
334 |
+
$this->addNotification($params, function ($code, $a, $b, $c, $transferred, $total) use($value) {
|
335 |
+
if ($code == \STREAM_NOTIFY_PROGRESS) {
|
336 |
+
$value($total, $transferred, null, null);
|
337 |
+
}
|
338 |
+
});
|
339 |
+
}
|
340 |
+
private function add_debug(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, &$options, $value, &$params)
|
341 |
+
{
|
342 |
+
if ($value === \false) {
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
static $map = [\STREAM_NOTIFY_CONNECT => 'CONNECT', \STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', \STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', \STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', \STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', \STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', \STREAM_NOTIFY_PROGRESS => 'PROGRESS', \STREAM_NOTIFY_FAILURE => 'FAILURE', \STREAM_NOTIFY_COMPLETED => 'COMPLETED', \STREAM_NOTIFY_RESOLVE => 'RESOLVE'];
|
346 |
+
static $args = ['severity', 'message', 'message_code', 'bytes_transferred', 'bytes_max'];
|
347 |
+
$value = \PixelCaffeine\Dependencies\GuzzleHttp\debug_resource($value);
|
348 |
+
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
|
349 |
+
$this->addNotification($params, function () use($ident, $value, $map, $args) {
|
350 |
+
$passed = \func_get_args();
|
351 |
+
$code = \array_shift($passed);
|
352 |
+
\fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
|
353 |
+
foreach (\array_filter($passed) as $i => $v) {
|
354 |
+
\fwrite($value, $args[$i] . ': "' . $v . '" ');
|
355 |
+
}
|
356 |
+
\fwrite($value, "\n");
|
357 |
+
});
|
358 |
+
}
|
359 |
+
private function addNotification(array &$params, callable $notify)
|
360 |
+
{
|
361 |
+
// Wrap the existing function if needed.
|
362 |
+
if (!isset($params['notification'])) {
|
363 |
+
$params['notification'] = $notify;
|
364 |
+
} else {
|
365 |
+
$params['notification'] = $this->callArray([$params['notification'], $notify]);
|
366 |
+
}
|
367 |
+
}
|
368 |
+
private function callArray(array $functions)
|
369 |
+
{
|
370 |
+
return function () use($functions) {
|
371 |
+
$args = \func_get_args();
|
372 |
+
foreach ($functions as $fn) {
|
373 |
+
\call_user_func_array($fn, $args);
|
374 |
+
}
|
375 |
+
};
|
376 |
+
}
|
377 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/HandlerStack.php
RENAMED
@@ -1,34 +1,22 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
6 |
-
use Psr\Http\Message\RequestInterface;
|
7 |
-
use Psr\Http\Message\ResponseInterface;
|
8 |
|
|
|
|
|
|
|
9 |
/**
|
10 |
* Creates a composed Guzzle handler function by stacking middlewares on top of
|
11 |
* an HTTP handler function.
|
12 |
-
*
|
13 |
-
* @final
|
14 |
*/
|
15 |
class HandlerStack
|
16 |
{
|
17 |
-
/**
|
18 |
-
* @var null|callable(RequestInterface, array): PromiseInterface
|
19 |
-
*/
|
20 |
private $handler;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @var array{(callable(callable(RequestInterface, array): PromiseInterface): callable), (string|null)}[]
|
24 |
-
*/
|
25 |
private $stack = [];
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var null|callable(RequestInterface, array): PromiseInterface
|
29 |
-
*/
|
30 |
private $cached;
|
31 |
-
|
32 |
/**
|
33 |
* Creates a default handler stack that can be used by clients.
|
34 |
*
|
@@ -40,41 +28,41 @@ class HandlerStack
|
|
40 |
* The returned handler stack can be passed to a client in the "handler"
|
41 |
* option.
|
42 |
*
|
43 |
-
* @param
|
44 |
-
*
|
45 |
-
*
|
|
|
|
|
46 |
*/
|
47 |
-
public static function create(
|
48 |
{
|
49 |
-
$stack = new self($handler ?:
|
50 |
-
$stack->push(Middleware::httpErrors(), 'http_errors');
|
51 |
-
$stack->push(Middleware::redirect(), 'allow_redirects');
|
52 |
-
$stack->push(Middleware::cookies(), 'cookies');
|
53 |
-
$stack->push(Middleware::prepareBody(), 'prepare_body');
|
54 |
-
|
55 |
return $stack;
|
56 |
}
|
57 |
-
|
58 |
/**
|
59 |
-
* @param
|
60 |
*/
|
61 |
public function __construct(callable $handler = null)
|
62 |
{
|
63 |
$this->handler = $handler;
|
64 |
}
|
65 |
-
|
66 |
/**
|
67 |
* Invokes the handler stack as a composed handler
|
68 |
*
|
|
|
|
|
|
|
69 |
* @return ResponseInterface|PromiseInterface
|
70 |
*/
|
71 |
-
public function __invoke(RequestInterface $request, array $options)
|
72 |
{
|
73 |
$handler = $this->resolve();
|
74 |
-
|
75 |
return $handler($request, $options);
|
76 |
}
|
77 |
-
|
78 |
/**
|
79 |
* Dumps a string representation of the stack.
|
80 |
*
|
@@ -84,11 +72,9 @@ class HandlerStack
|
|
84 |
{
|
85 |
$depth = 0;
|
86 |
$stack = [];
|
87 |
-
|
88 |
-
if ($this->handler !== null) {
|
89 |
$stack[] = "0) Handler: " . $this->debugCallable($this->handler);
|
90 |
}
|
91 |
-
|
92 |
$result = '';
|
93 |
foreach (\array_reverse($this->stack) as $tuple) {
|
94 |
$depth++;
|
@@ -97,142 +83,132 @@ class HandlerStack
|
|
97 |
$result = "> {$str}\n{$result}";
|
98 |
$stack[] = $str;
|
99 |
}
|
100 |
-
|
101 |
foreach (\array_keys($stack) as $k) {
|
102 |
$result .= "< {$stack[$k]}\n";
|
103 |
}
|
104 |
-
|
105 |
return $result;
|
106 |
}
|
107 |
-
|
108 |
/**
|
109 |
* Set the HTTP handler that actually returns a promise.
|
110 |
*
|
111 |
-
* @param callable
|
112 |
-
*
|
113 |
*/
|
114 |
-
public function setHandler(callable $handler)
|
115 |
{
|
116 |
$this->handler = $handler;
|
117 |
$this->cached = null;
|
118 |
}
|
119 |
-
|
120 |
/**
|
121 |
* Returns true if the builder has a handler.
|
|
|
|
|
122 |
*/
|
123 |
-
public function hasHandler()
|
124 |
{
|
125 |
-
return $this->handler
|
126 |
}
|
127 |
-
|
128 |
/**
|
129 |
* Unshift a middleware to the bottom of the stack.
|
130 |
*
|
131 |
-
* @param callable
|
132 |
-
* @param string
|
133 |
*/
|
134 |
-
public function unshift(callable $middleware,
|
135 |
{
|
136 |
\array_unshift($this->stack, [$middleware, $name]);
|
137 |
$this->cached = null;
|
138 |
}
|
139 |
-
|
140 |
/**
|
141 |
* Push a middleware to the top of the stack.
|
142 |
*
|
143 |
-
* @param callable
|
144 |
-
* @param string
|
145 |
*/
|
146 |
-
public function push(callable $middleware,
|
147 |
{
|
148 |
$this->stack[] = [$middleware, $name];
|
149 |
$this->cached = null;
|
150 |
}
|
151 |
-
|
152 |
/**
|
153 |
* Add a middleware before another middleware by name.
|
154 |
*
|
155 |
-
* @param string
|
156 |
-
* @param callable
|
157 |
-
* @param string
|
158 |
*/
|
159 |
-
public function before(
|
160 |
{
|
161 |
-
$this->splice($findName, $withName, $middleware, true);
|
162 |
}
|
163 |
-
|
164 |
/**
|
165 |
* Add a middleware after another middleware by name.
|
166 |
*
|
167 |
-
* @param string
|
168 |
-
* @param callable
|
169 |
-
* @param string
|
170 |
*/
|
171 |
-
public function after(
|
172 |
{
|
173 |
-
$this->splice($findName, $withName, $middleware, false);
|
174 |
}
|
175 |
-
|
176 |
/**
|
177 |
* Remove a middleware by instance or name from the stack.
|
178 |
*
|
179 |
* @param callable|string $remove Middleware to remove by instance or name.
|
180 |
*/
|
181 |
-
public function remove($remove)
|
182 |
{
|
183 |
$this->cached = null;
|
184 |
$idx = \is_callable($remove) ? 0 : 1;
|
185 |
-
$this->stack = \array_values(\array_filter(
|
186 |
-
$
|
187 |
-
|
188 |
-
return $tuple[$idx] !== $remove;
|
189 |
-
}
|
190 |
-
));
|
191 |
}
|
192 |
-
|
193 |
/**
|
194 |
* Compose the middleware and handler into a single callable function.
|
195 |
*
|
196 |
-
* @return callable
|
197 |
*/
|
198 |
-
public function resolve()
|
199 |
{
|
200 |
-
if (
|
201 |
-
if (($prev = $this->handler)
|
202 |
throw new \LogicException('No handler has been specified');
|
203 |
}
|
204 |
-
|
205 |
foreach (\array_reverse($this->stack) as $fn) {
|
206 |
-
/** @var callable(RequestInterface, array): PromiseInterface $prev */
|
207 |
$prev = $fn[0]($prev);
|
208 |
}
|
209 |
-
|
210 |
$this->cached = $prev;
|
211 |
}
|
212 |
-
|
213 |
return $this->cached;
|
214 |
}
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
217 |
{
|
218 |
foreach ($this->stack as $k => $v) {
|
219 |
if ($v[1] === $name) {
|
220 |
return $k;
|
221 |
}
|
222 |
}
|
223 |
-
|
224 |
-
throw new \InvalidArgumentException("Middleware not found: $name");
|
225 |
}
|
226 |
-
|
227 |
/**
|
228 |
* Splices a function into the middleware list at a specific position.
|
|
|
|
|
|
|
|
|
|
|
229 |
*/
|
230 |
-
private function splice(
|
231 |
{
|
232 |
$this->cached = null;
|
233 |
$idx = $this->findByName($findName);
|
234 |
$tuple = [$middleware, $withName];
|
235 |
-
|
236 |
if ($before) {
|
237 |
if ($idx === 0) {
|
238 |
\array_unshift($this->stack, $tuple);
|
@@ -247,25 +223,21 @@ class HandlerStack
|
|
247 |
\array_splice($this->stack, $idx, 1, $replacement);
|
248 |
}
|
249 |
}
|
250 |
-
|
251 |
/**
|
252 |
* Provides a debug string for a given callable.
|
253 |
*
|
254 |
-
* @param callable $fn Function to write as a string.
|
|
|
|
|
255 |
*/
|
256 |
-
private function debugCallable($fn)
|
257 |
{
|
258 |
if (\is_string($fn)) {
|
259 |
return "callable({$fn})";
|
260 |
}
|
261 |
-
|
262 |
if (\is_array($fn)) {
|
263 |
-
return \is_string($fn[0])
|
264 |
-
? "callable({$fn[0]}::{$fn[1]})"
|
265 |
-
: "callable(['" . \get_class($fn[0]) . "', '{$fn[1]}'])";
|
266 |
}
|
267 |
-
|
268 |
-
/** @var object $fn */
|
269 |
return 'callable(' . \spl_object_hash($fn) . ')';
|
270 |
}
|
271 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
8 |
/**
|
9 |
* Creates a composed Guzzle handler function by stacking middlewares on top of
|
10 |
* an HTTP handler function.
|
|
|
|
|
11 |
*/
|
12 |
class HandlerStack
|
13 |
{
|
14 |
+
/** @var callable|null */
|
|
|
|
|
15 |
private $handler;
|
16 |
+
/** @var array */
|
|
|
|
|
|
|
17 |
private $stack = [];
|
18 |
+
/** @var callable|null */
|
|
|
|
|
|
|
19 |
private $cached;
|
|
|
20 |
/**
|
21 |
* Creates a default handler stack that can be used by clients.
|
22 |
*
|
28 |
* The returned handler stack can be passed to a client in the "handler"
|
29 |
* option.
|
30 |
*
|
31 |
+
* @param callable $handler HTTP handler function to use with the stack. If no
|
32 |
+
* handler is provided, the best handler for your
|
33 |
+
* system will be utilized.
|
34 |
+
*
|
35 |
+
* @return HandlerStack
|
36 |
*/
|
37 |
+
public static function create(callable $handler = null)
|
38 |
{
|
39 |
+
$stack = new self($handler ?: choose_handler());
|
40 |
+
$stack->push(\PixelCaffeine\Dependencies\GuzzleHttp\Middleware::httpErrors(), 'http_errors');
|
41 |
+
$stack->push(\PixelCaffeine\Dependencies\GuzzleHttp\Middleware::redirect(), 'allow_redirects');
|
42 |
+
$stack->push(\PixelCaffeine\Dependencies\GuzzleHttp\Middleware::cookies(), 'cookies');
|
43 |
+
$stack->push(\PixelCaffeine\Dependencies\GuzzleHttp\Middleware::prepareBody(), 'prepare_body');
|
|
|
44 |
return $stack;
|
45 |
}
|
|
|
46 |
/**
|
47 |
+
* @param callable $handler Underlying HTTP handler.
|
48 |
*/
|
49 |
public function __construct(callable $handler = null)
|
50 |
{
|
51 |
$this->handler = $handler;
|
52 |
}
|
|
|
53 |
/**
|
54 |
* Invokes the handler stack as a composed handler
|
55 |
*
|
56 |
+
* @param RequestInterface $request
|
57 |
+
* @param array $options
|
58 |
+
*
|
59 |
* @return ResponseInterface|PromiseInterface
|
60 |
*/
|
61 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
62 |
{
|
63 |
$handler = $this->resolve();
|
|
|
64 |
return $handler($request, $options);
|
65 |
}
|
|
|
66 |
/**
|
67 |
* Dumps a string representation of the stack.
|
68 |
*
|
72 |
{
|
73 |
$depth = 0;
|
74 |
$stack = [];
|
75 |
+
if ($this->handler) {
|
|
|
76 |
$stack[] = "0) Handler: " . $this->debugCallable($this->handler);
|
77 |
}
|
|
|
78 |
$result = '';
|
79 |
foreach (\array_reverse($this->stack) as $tuple) {
|
80 |
$depth++;
|
83 |
$result = "> {$str}\n{$result}";
|
84 |
$stack[] = $str;
|
85 |
}
|
|
|
86 |
foreach (\array_keys($stack) as $k) {
|
87 |
$result .= "< {$stack[$k]}\n";
|
88 |
}
|
|
|
89 |
return $result;
|
90 |
}
|
|
|
91 |
/**
|
92 |
* Set the HTTP handler that actually returns a promise.
|
93 |
*
|
94 |
+
* @param callable $handler Accepts a request and array of options and
|
95 |
+
* returns a Promise.
|
96 |
*/
|
97 |
+
public function setHandler(callable $handler)
|
98 |
{
|
99 |
$this->handler = $handler;
|
100 |
$this->cached = null;
|
101 |
}
|
|
|
102 |
/**
|
103 |
* Returns true if the builder has a handler.
|
104 |
+
*
|
105 |
+
* @return bool
|
106 |
*/
|
107 |
+
public function hasHandler()
|
108 |
{
|
109 |
+
return (bool) $this->handler;
|
110 |
}
|
|
|
111 |
/**
|
112 |
* Unshift a middleware to the bottom of the stack.
|
113 |
*
|
114 |
+
* @param callable $middleware Middleware function
|
115 |
+
* @param string $name Name to register for this middleware.
|
116 |
*/
|
117 |
+
public function unshift(callable $middleware, $name = null)
|
118 |
{
|
119 |
\array_unshift($this->stack, [$middleware, $name]);
|
120 |
$this->cached = null;
|
121 |
}
|
|
|
122 |
/**
|
123 |
* Push a middleware to the top of the stack.
|
124 |
*
|
125 |
+
* @param callable $middleware Middleware function
|
126 |
+
* @param string $name Name to register for this middleware.
|
127 |
*/
|
128 |
+
public function push(callable $middleware, $name = '')
|
129 |
{
|
130 |
$this->stack[] = [$middleware, $name];
|
131 |
$this->cached = null;
|
132 |
}
|
|
|
133 |
/**
|
134 |
* Add a middleware before another middleware by name.
|
135 |
*
|
136 |
+
* @param string $findName Middleware to find
|
137 |
+
* @param callable $middleware Middleware function
|
138 |
+
* @param string $withName Name to register for this middleware.
|
139 |
*/
|
140 |
+
public function before($findName, callable $middleware, $withName = '')
|
141 |
{
|
142 |
+
$this->splice($findName, $withName, $middleware, \true);
|
143 |
}
|
|
|
144 |
/**
|
145 |
* Add a middleware after another middleware by name.
|
146 |
*
|
147 |
+
* @param string $findName Middleware to find
|
148 |
+
* @param callable $middleware Middleware function
|
149 |
+
* @param string $withName Name to register for this middleware.
|
150 |
*/
|
151 |
+
public function after($findName, callable $middleware, $withName = '')
|
152 |
{
|
153 |
+
$this->splice($findName, $withName, $middleware, \false);
|
154 |
}
|
|
|
155 |
/**
|
156 |
* Remove a middleware by instance or name from the stack.
|
157 |
*
|
158 |
* @param callable|string $remove Middleware to remove by instance or name.
|
159 |
*/
|
160 |
+
public function remove($remove)
|
161 |
{
|
162 |
$this->cached = null;
|
163 |
$idx = \is_callable($remove) ? 0 : 1;
|
164 |
+
$this->stack = \array_values(\array_filter($this->stack, function ($tuple) use($idx, $remove) {
|
165 |
+
return $tuple[$idx] !== $remove;
|
166 |
+
}));
|
|
|
|
|
|
|
167 |
}
|
|
|
168 |
/**
|
169 |
* Compose the middleware and handler into a single callable function.
|
170 |
*
|
171 |
+
* @return callable
|
172 |
*/
|
173 |
+
public function resolve()
|
174 |
{
|
175 |
+
if (!$this->cached) {
|
176 |
+
if (!($prev = $this->handler)) {
|
177 |
throw new \LogicException('No handler has been specified');
|
178 |
}
|
|
|
179 |
foreach (\array_reverse($this->stack) as $fn) {
|
|
|
180 |
$prev = $fn[0]($prev);
|
181 |
}
|
|
|
182 |
$this->cached = $prev;
|
183 |
}
|
|
|
184 |
return $this->cached;
|
185 |
}
|
186 |
+
/**
|
187 |
+
* @param string $name
|
188 |
+
* @return int
|
189 |
+
*/
|
190 |
+
private function findByName($name)
|
191 |
{
|
192 |
foreach ($this->stack as $k => $v) {
|
193 |
if ($v[1] === $name) {
|
194 |
return $k;
|
195 |
}
|
196 |
}
|
197 |
+
throw new \InvalidArgumentException("Middleware not found: {$name}");
|
|
|
198 |
}
|
|
|
199 |
/**
|
200 |
* Splices a function into the middleware list at a specific position.
|
201 |
+
*
|
202 |
+
* @param string $findName
|
203 |
+
* @param string $withName
|
204 |
+
* @param callable $middleware
|
205 |
+
* @param bool $before
|
206 |
*/
|
207 |
+
private function splice($findName, $withName, callable $middleware, $before)
|
208 |
{
|
209 |
$this->cached = null;
|
210 |
$idx = $this->findByName($findName);
|
211 |
$tuple = [$middleware, $withName];
|
|
|
212 |
if ($before) {
|
213 |
if ($idx === 0) {
|
214 |
\array_unshift($this->stack, $tuple);
|
223 |
\array_splice($this->stack, $idx, 1, $replacement);
|
224 |
}
|
225 |
}
|
|
|
226 |
/**
|
227 |
* Provides a debug string for a given callable.
|
228 |
*
|
229 |
+
* @param array|callable $fn Function to write as a string.
|
230 |
+
*
|
231 |
+
* @return string
|
232 |
*/
|
233 |
+
private function debugCallable($fn)
|
234 |
{
|
235 |
if (\is_string($fn)) {
|
236 |
return "callable({$fn})";
|
237 |
}
|
|
|
238 |
if (\is_array($fn)) {
|
239 |
+
return \is_string($fn[0]) ? "callable({$fn[0]}::{$fn[1]})" : "callable(['" . \get_class($fn[0]) . "', '{$fn[1]}'])";
|
|
|
|
|
240 |
}
|
|
|
|
|
241 |
return 'callable(' . \spl_object_hash($fn) . ')';
|
242 |
}
|
243 |
}
|
third-party/vendor/guzzlehttp/guzzle/src/MessageFormatter.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
8 |
+
/**
|
9 |
+
* Formats log messages using variable substitutions for requests, responses,
|
10 |
+
* and other transactional data.
|
11 |
+
*
|
12 |
+
* The following variable substitutions are supported:
|
13 |
+
*
|
14 |
+
* - {request}: Full HTTP request message
|
15 |
+
* - {response}: Full HTTP response message
|
16 |
+
* - {ts}: ISO 8601 date in GMT
|
17 |
+
* - {date_iso_8601} ISO 8601 date in GMT
|
18 |
+
* - {date_common_log} Apache common log date using the configured timezone.
|
19 |
+
* - {host}: Host of the request
|
20 |
+
* - {method}: Method of the request
|
21 |
+
* - {uri}: URI of the request
|
22 |
+
* - {version}: Protocol version
|
23 |
+
* - {target}: Request target of the request (path + query + fragment)
|
24 |
+
* - {hostname}: Hostname of the machine that sent the request
|
25 |
+
* - {code}: Status code of the response (if available)
|
26 |
+
* - {phrase}: Reason phrase of the response (if available)
|
27 |
+
* - {error}: Any error messages (if available)
|
28 |
+
* - {req_header_*}: Replace `*` with the lowercased name of a request header to add to the message
|
29 |
+
* - {res_header_*}: Replace `*` with the lowercased name of a response header to add to the message
|
30 |
+
* - {req_headers}: Request headers
|
31 |
+
* - {res_headers}: Response headers
|
32 |
+
* - {req_body}: Request body
|
33 |
+
* - {res_body}: Response body
|
34 |
+
*/
|
35 |
+
class MessageFormatter
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Apache Common Log Format.
|
39 |
+
* @link http://httpd.apache.org/docs/2.4/logs.html#common
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
|
43 |
+
const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
|
44 |
+
const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
|
45 |
+
/** @var string Template used to format log messages */
|
46 |
+
private $template;
|
47 |
+
/**
|
48 |
+
* @param string $template Log message template
|
49 |
+
*/
|
50 |
+
public function __construct($template = self::CLF)
|
51 |
+
{
|
52 |
+
$this->template = $template ?: self::CLF;
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* Returns a formatted message string.
|
56 |
+
*
|
57 |
+
* @param RequestInterface $request Request that was sent
|
58 |
+
* @param ResponseInterface $response Response that was received
|
59 |
+
* @param \Exception $error Exception that was received
|
60 |
+
*
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function format(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, \Exception $error = null)
|
64 |
+
{
|
65 |
+
$cache = [];
|
66 |
+
return \preg_replace_callback('/{\\s*([A-Za-z_\\-\\.0-9]+)\\s*}/', function (array $matches) use($request, $response, $error, &$cache) {
|
67 |
+
if (isset($cache[$matches[1]])) {
|
68 |
+
return $cache[$matches[1]];
|
69 |
+
}
|
70 |
+
$result = '';
|
71 |
+
switch ($matches[1]) {
|
72 |
+
case 'request':
|
73 |
+
$result = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\str($request);
|
74 |
+
break;
|
75 |
+
case 'response':
|
76 |
+
$result = $response ? \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\str($response) : '';
|
77 |
+
break;
|
78 |
+
case 'req_headers':
|
79 |
+
$result = \trim($request->getMethod() . ' ' . $request->getRequestTarget()) . ' HTTP/' . $request->getProtocolVersion() . "\r\n" . $this->headers($request);
|
80 |
+
break;
|
81 |
+
case 'res_headers':
|
82 |
+
$result = $response ? \sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()) . "\r\n" . $this->headers($response) : 'NULL';
|
83 |
+
break;
|
84 |
+
case 'req_body':
|
85 |
+
$result = $request->getBody();
|
86 |
+
break;
|
87 |
+
case 'res_body':
|
88 |
+
$result = $response ? $response->getBody() : 'NULL';
|
89 |
+
break;
|
90 |
+
case 'ts':
|
91 |
+
case 'date_iso_8601':
|
92 |
+
$result = \gmdate('c');
|
93 |
+
break;
|
94 |
+
case 'date_common_log':
|
95 |
+
$result = \date('d/M/Y:H:i:s O');
|
96 |
+
break;
|
97 |
+
case 'method':
|
98 |
+
$result = $request->getMethod();
|
99 |
+
break;
|
100 |
+
case 'version':
|
101 |
+
$result = $request->getProtocolVersion();
|
102 |
+
break;
|
103 |
+
case 'uri':
|
104 |
+
case 'url':
|
105 |
+
$result = $request->getUri();
|
106 |
+
break;
|
107 |
+
case 'target':
|
108 |
+
$result = $request->getRequestTarget();
|
109 |
+
break;
|
110 |
+
case 'req_version':
|
111 |
+
$result = $request->getProtocolVersion();
|
112 |
+
break;
|
113 |
+
case 'res_version':
|
114 |
+
$result = $response ? $response->getProtocolVersion() : 'NULL';
|
115 |
+
break;
|
116 |
+
case 'host':
|
117 |
+
$result = $request->getHeaderLine('Host');
|
118 |
+
break;
|
119 |
+
case 'hostname':
|
120 |
+
$result = \gethostname();
|
121 |
+
break;
|
122 |
+
case 'code':
|
123 |
+
$result = $response ? $response->getStatusCode() : 'NULL';
|
124 |
+
break;
|
125 |
+
case 'phrase':
|
126 |
+
$result = $response ? $response->getReasonPhrase() : 'NULL';
|
127 |
+
break;
|
128 |
+
case 'error':
|
129 |
+
$result = $error ? $error->getMessage() : 'NULL';
|
130 |
+
break;
|
131 |
+
default:
|
132 |
+
// handle prefixed dynamic headers
|
133 |
+
if (\strpos($matches[1], 'req_header_') === 0) {
|
134 |
+
$result = $request->getHeaderLine(\substr($matches[1], 11));
|
135 |
+
} elseif (\strpos($matches[1], 'res_header_') === 0) {
|
136 |
+
$result = $response ? $response->getHeaderLine(\substr($matches[1], 11)) : 'NULL';
|
137 |
+
}
|
138 |
+
}
|
139 |
+
$cache[$matches[1]] = $result;
|
140 |
+
return $result;
|
141 |
+
}, $this->template);
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* Get headers from message as string
|
145 |
+
*
|
146 |
+
* @return string
|
147 |
+
*/
|
148 |
+
private function headers(\PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface $message)
|
149 |
+
{
|
150 |
+
$result = '';
|
151 |
+
foreach ($message->getHeaders() as $name => $values) {
|
152 |
+
$result .= $name . ': ' . \implode(', ', $values) . "\r\n";
|
153 |
+
}
|
154 |
+
return \trim($result);
|
155 |
+
}
|
156 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Middleware.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJarInterface;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectedPromise;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
10 |
+
use PixelCaffeine\Dependencies\Psr\Log\LoggerInterface;
|
11 |
+
/**
|
12 |
+
* Functions used to create and wrap handlers with handler middleware.
|
13 |
+
*/
|
14 |
+
final class Middleware
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Middleware that adds cookies to requests.
|
18 |
+
*
|
19 |
+
* The options array must be set to a CookieJarInterface in order to use
|
20 |
+
* cookies. This is typically handled for you by a client.
|
21 |
+
*
|
22 |
+
* @return callable Returns a function that accepts the next handler.
|
23 |
+
*/
|
24 |
+
public static function cookies()
|
25 |
+
{
|
26 |
+
return function (callable $handler) {
|
27 |
+
return function ($request, array $options) use($handler) {
|
28 |
+
if (empty($options['cookies'])) {
|
29 |
+
return $handler($request, $options);
|
30 |
+
} elseif (!$options['cookies'] instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Cookie\CookieJarInterface) {
|
31 |
+
throw new \InvalidArgumentException('PixelCaffeine\\Dependencies\\cookies must be an instance of GuzzleHttp\\Cookie\\CookieJarInterface');
|
32 |
+
}
|
33 |
+
$cookieJar = $options['cookies'];
|
34 |
+
$request = $cookieJar->withCookieHeader($request);
|
35 |
+
return $handler($request, $options)->then(function ($response) use($cookieJar, $request) {
|
36 |
+
$cookieJar->extractCookies($request, $response);
|
37 |
+
return $response;
|
38 |
+
});
|
39 |
+
};
|
40 |
+
};
|
41 |
+
}
|
42 |
+
/**
|
43 |
+
* Middleware that throws exceptions for 4xx or 5xx responses when the
|
44 |
+
* "http_error" request option is set to true.
|
45 |
+
*
|
46 |
+
* @return callable Returns a function that accepts the next handler.
|
47 |
+
*/
|
48 |
+
public static function httpErrors()
|
49 |
+
{
|
50 |
+
return function (callable $handler) {
|
51 |
+
return function ($request, array $options) use($handler) {
|
52 |
+
if (empty($options['http_errors'])) {
|
53 |
+
return $handler($request, $options);
|
54 |
+
}
|
55 |
+
return $handler($request, $options)->then(function (\PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response) use($request) {
|
56 |
+
$code = $response->getStatusCode();
|
57 |
+
if ($code < 400) {
|
58 |
+
return $response;
|
59 |
+
}
|
60 |
+
throw \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException::create($request, $response);
|
61 |
+
});
|
62 |
+
};
|
63 |
+
};
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* Middleware that pushes history data to an ArrayAccess container.
|
67 |
+
*
|
68 |
+
* @param array|\ArrayAccess $container Container to hold the history (by reference).
|
69 |
+
*
|
70 |
+
* @return callable Returns a function that accepts the next handler.
|
71 |
+
* @throws \InvalidArgumentException if container is not an array or ArrayAccess.
|
72 |
+
*/
|
73 |
+
public static function history(&$container)
|
74 |
+
{
|
75 |
+
if (!\is_array($container) && !$container instanceof \ArrayAccess) {
|
76 |
+
throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
|
77 |
+
}
|
78 |
+
return function (callable $handler) use(&$container) {
|
79 |
+
return function ($request, array $options) use($handler, &$container) {
|
80 |
+
return $handler($request, $options)->then(function ($value) use($request, &$container, $options) {
|
81 |
+
$container[] = ['request' => $request, 'response' => $value, 'error' => null, 'options' => $options];
|
82 |
+
return $value;
|
83 |
+
}, function ($reason) use($request, &$container, $options) {
|
84 |
+
$container[] = ['request' => $request, 'response' => null, 'error' => $reason, 'options' => $options];
|
85 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($reason);
|
86 |
+
});
|
87 |
+
};
|
88 |
+
};
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* Middleware that invokes a callback before and after sending a request.
|
92 |
+
*
|
93 |
+
* The provided listener cannot modify or alter the response. It simply
|
94 |
+
* "taps" into the chain to be notified before returning the promise. The
|
95 |
+
* before listener accepts a request and options array, and the after
|
96 |
+
* listener accepts a request, options array, and response promise.
|
97 |
+
*
|
98 |
+
* @param callable $before Function to invoke before forwarding the request.
|
99 |
+
* @param callable $after Function invoked after forwarding.
|
100 |
+
*
|
101 |
+
* @return callable Returns a function that accepts the next handler.
|
102 |
+
*/
|
103 |
+
public static function tap(callable $before = null, callable $after = null)
|
104 |
+
{
|
105 |
+
return function (callable $handler) use($before, $after) {
|
106 |
+
return function ($request, array $options) use($handler, $before, $after) {
|
107 |
+
if ($before) {
|
108 |
+
$before($request, $options);
|
109 |
+
}
|
110 |
+
$response = $handler($request, $options);
|
111 |
+
if ($after) {
|
112 |
+
$after($request, $options, $response);
|
113 |
+
}
|
114 |
+
return $response;
|
115 |
+
};
|
116 |
+
};
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* Middleware that handles request redirects.
|
120 |
+
*
|
121 |
+
* @return callable Returns a function that accepts the next handler.
|
122 |
+
*/
|
123 |
+
public static function redirect()
|
124 |
+
{
|
125 |
+
return function (callable $handler) {
|
126 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\RedirectMiddleware($handler);
|
127 |
+
};
|
128 |
+
}
|
129 |
+
/**
|
130 |
+
* Middleware that retries requests based on the boolean result of
|
131 |
+
* invoking the provided "decider" function.
|
132 |
+
*
|
133 |
+
* If no delay function is provided, a simple implementation of exponential
|
134 |
+
* backoff will be utilized.
|
135 |
+
*
|
136 |
+
* @param callable $decider Function that accepts the number of retries,
|
137 |
+
* a request, [response], and [exception] and
|
138 |
+
* returns true if the request is to be retried.
|
139 |
+
* @param callable $delay Function that accepts the number of retries and
|
140 |
+
* returns the number of milliseconds to delay.
|
141 |
+
*
|
142 |
+
* @return callable Returns a function that accepts the next handler.
|
143 |
+
*/
|
144 |
+
public static function retry(callable $decider, callable $delay = null)
|
145 |
+
{
|
146 |
+
return function (callable $handler) use($decider, $delay) {
|
147 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\RetryMiddleware($decider, $handler, $delay);
|
148 |
+
};
|
149 |
+
}
|
150 |
+
/**
|
151 |
+
* Middleware that logs requests, responses, and errors using a message
|
152 |
+
* formatter.
|
153 |
+
*
|
154 |
+
* @param LoggerInterface $logger Logs messages.
|
155 |
+
* @param MessageFormatter $formatter Formatter used to create message strings.
|
156 |
+
* @param string $logLevel Level at which to log requests.
|
157 |
+
*
|
158 |
+
* @return callable Returns a function that accepts the next handler.
|
159 |
+
*/
|
160 |
+
public static function log(\PixelCaffeine\Dependencies\Psr\Log\LoggerInterface $logger, \PixelCaffeine\Dependencies\GuzzleHttp\MessageFormatter $formatter, $logLevel = 'info')
|
161 |
+
{
|
162 |
+
return function (callable $handler) use($logger, $formatter, $logLevel) {
|
163 |
+
return function ($request, array $options) use($handler, $logger, $formatter, $logLevel) {
|
164 |
+
return $handler($request, $options)->then(function ($response) use($logger, $request, $formatter, $logLevel) {
|
165 |
+
$message = $formatter->format($request, $response);
|
166 |
+
$logger->log($logLevel, $message);
|
167 |
+
return $response;
|
168 |
+
}, function ($reason) use($logger, $request, $formatter) {
|
169 |
+
$response = $reason instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Exception\RequestException ? $reason->getResponse() : null;
|
170 |
+
$message = $formatter->format($request, $response, $reason);
|
171 |
+
$logger->notice($message);
|
172 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($reason);
|
173 |
+
});
|
174 |
+
};
|
175 |
+
};
|
176 |
+
}
|
177 |
+
/**
|
178 |
+
* This middleware adds a default content-type if possible, a default
|
179 |
+
* content-length or transfer-encoding header, and the expect header.
|
180 |
+
*
|
181 |
+
* @return callable
|
182 |
+
*/
|
183 |
+
public static function prepareBody()
|
184 |
+
{
|
185 |
+
return function (callable $handler) {
|
186 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\PrepareBodyMiddleware($handler);
|
187 |
+
};
|
188 |
+
}
|
189 |
+
/**
|
190 |
+
* Middleware that applies a map function to the request before passing to
|
191 |
+
* the next handler.
|
192 |
+
*
|
193 |
+
* @param callable $fn Function that accepts a RequestInterface and returns
|
194 |
+
* a RequestInterface.
|
195 |
+
* @return callable
|
196 |
+
*/
|
197 |
+
public static function mapRequest(callable $fn)
|
198 |
+
{
|
199 |
+
return function (callable $handler) use($fn) {
|
200 |
+
return function ($request, array $options) use($handler, $fn) {
|
201 |
+
return $handler($fn($request), $options);
|
202 |
+
};
|
203 |
+
};
|
204 |
+
}
|
205 |
+
/**
|
206 |
+
* Middleware that applies a map function to the resolved promise's
|
207 |
+
* response.
|
208 |
+
*
|
209 |
+
* @param callable $fn Function that accepts a ResponseInterface and
|
210 |
+
* returns a ResponseInterface.
|
211 |
+
* @return callable
|
212 |
+
*/
|
213 |
+
public static function mapResponse(callable $fn)
|
214 |
+
{
|
215 |
+
return function (callable $handler) use($fn) {
|
216 |
+
return function ($request, array $options) use($handler, $fn) {
|
217 |
+
return $handler($request, $options)->then($fn);
|
218 |
+
};
|
219 |
+
};
|
220 |
+
}
|
221 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/Pool.php
RENAMED
@@ -1,13 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use GuzzleHttp\Promise as P;
|
6 |
-
use GuzzleHttp\Promise\EachPromise;
|
7 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
8 |
-
use GuzzleHttp\Promise\PromisorInterface;
|
9 |
-
use Psr\Http\Message\RequestInterface;
|
10 |
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Sends an iterator of requests concurrently using a capped pool size.
|
13 |
*
|
@@ -18,63 +16,58 @@ use Psr\Http\Message\RequestInterface;
|
|
18 |
* When a function is yielded by the iterator, the function is provided the
|
19 |
* "request_options" array that should be merged on top of any existing
|
20 |
* options, and the function MUST then return a wait-able promise.
|
21 |
-
*
|
22 |
-
* @final
|
23 |
*/
|
24 |
-
class Pool implements PromisorInterface
|
25 |
{
|
26 |
-
/**
|
27 |
-
* @var EachPromise
|
28 |
-
*/
|
29 |
private $each;
|
30 |
-
|
31 |
/**
|
32 |
* @param ClientInterface $client Client used to send the requests.
|
33 |
* @param array|\Iterator $requests Requests or functions that return
|
34 |
* requests to send concurrently.
|
35 |
* @param array $config Associative array of options
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
*/
|
41 |
-
public function __construct(ClientInterface $client, $requests, array $config = [])
|
42 |
{
|
43 |
-
|
|
|
|
|
|
|
44 |
$config['concurrency'] = 25;
|
45 |
}
|
46 |
-
|
47 |
if (isset($config['options'])) {
|
48 |
$opts = $config['options'];
|
49 |
unset($config['options']);
|
50 |
} else {
|
51 |
$opts = [];
|
52 |
}
|
53 |
-
|
54 |
-
$
|
55 |
-
$requests = static function () use ($iterable, $client, $opts) {
|
56 |
foreach ($iterable as $key => $rfn) {
|
57 |
-
if ($rfn instanceof RequestInterface) {
|
58 |
-
yield $key => $client->sendAsync($rfn, $opts);
|
59 |
} elseif (\is_callable($rfn)) {
|
60 |
-
yield $key => $rfn($opts);
|
61 |
} else {
|
62 |
-
throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7
|
63 |
}
|
64 |
}
|
65 |
};
|
66 |
-
|
67 |
-
$this->each = new EachPromise($requests(), $config);
|
68 |
}
|
69 |
-
|
70 |
/**
|
71 |
* Get promise
|
|
|
|
|
72 |
*/
|
73 |
-
public function promise()
|
74 |
{
|
75 |
return $this->each->promise();
|
76 |
}
|
77 |
-
|
78 |
/**
|
79 |
* Sends multiple requests concurrently and returns an array of responses
|
80 |
* and exceptions that uses the same ordering as the provided requests.
|
@@ -86,14 +79,13 @@ class Pool implements PromisorInterface
|
|
86 |
* @param ClientInterface $client Client used to send the requests
|
87 |
* @param array|\Iterator $requests Requests to send concurrently.
|
88 |
* @param array $options Passes through the options available in
|
89 |
-
* {@see
|
90 |
*
|
91 |
* @return array Returns an array containing the response or an exception
|
92 |
* in the same order that the requests were sent.
|
93 |
-
*
|
94 |
* @throws \InvalidArgumentException if the event format is incorrect.
|
95 |
*/
|
96 |
-
public static function batch(ClientInterface $client, $requests, array $options = [])
|
97 |
{
|
98 |
$res = [];
|
99 |
self::cmpCallback($options, 'fulfilled', $res);
|
@@ -101,22 +93,22 @@ class Pool implements PromisorInterface
|
|
101 |
$pool = new static($client, $requests, $options);
|
102 |
$pool->promise()->wait();
|
103 |
\ksort($res);
|
104 |
-
|
105 |
return $res;
|
106 |
}
|
107 |
-
|
108 |
/**
|
109 |
* Execute callback(s)
|
|
|
|
|
110 |
*/
|
111 |
-
private static function cmpCallback(array &$options,
|
112 |
{
|
113 |
if (!isset($options[$name])) {
|
114 |
-
$options[$name] =
|
115 |
$results[$k] = $v;
|
116 |
};
|
117 |
} else {
|
118 |
$currentFn = $options[$name];
|
119 |
-
$options[$name] =
|
120 |
$currentFn($v, $k);
|
121 |
$results[$k] = $v;
|
122 |
};
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\EachPromise;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromisorInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
9 |
/**
|
10 |
* Sends an iterator of requests concurrently using a capped pool size.
|
11 |
*
|
16 |
* When a function is yielded by the iterator, the function is provided the
|
17 |
* "request_options" array that should be merged on top of any existing
|
18 |
* options, and the function MUST then return a wait-able promise.
|
|
|
|
|
19 |
*/
|
20 |
+
class Pool implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromisorInterface
|
21 |
{
|
22 |
+
/** @var EachPromise */
|
|
|
|
|
23 |
private $each;
|
|
|
24 |
/**
|
25 |
* @param ClientInterface $client Client used to send the requests.
|
26 |
* @param array|\Iterator $requests Requests or functions that return
|
27 |
* requests to send concurrently.
|
28 |
* @param array $config Associative array of options
|
29 |
+
* - concurrency: (int) Maximum number of requests to send concurrently
|
30 |
+
* - options: Array of request options to apply to each request.
|
31 |
+
* - fulfilled: (callable) Function to invoke when a request completes.
|
32 |
+
* - rejected: (callable) Function to invoke when a request is rejected.
|
33 |
*/
|
34 |
+
public function __construct(\PixelCaffeine\Dependencies\GuzzleHttp\ClientInterface $client, $requests, array $config = [])
|
35 |
{
|
36 |
+
// Backwards compatibility.
|
37 |
+
if (isset($config['pool_size'])) {
|
38 |
+
$config['concurrency'] = $config['pool_size'];
|
39 |
+
} elseif (!isset($config['concurrency'])) {
|
40 |
$config['concurrency'] = 25;
|
41 |
}
|
|
|
42 |
if (isset($config['options'])) {
|
43 |
$opts = $config['options'];
|
44 |
unset($config['options']);
|
45 |
} else {
|
46 |
$opts = [];
|
47 |
}
|
48 |
+
$iterable = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\iter_for($requests);
|
49 |
+
$requests = function () use($iterable, $client, $opts) {
|
|
|
50 |
foreach ($iterable as $key => $rfn) {
|
51 |
+
if ($rfn instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface) {
|
52 |
+
(yield $key => $client->sendAsync($rfn, $opts));
|
53 |
} elseif (\is_callable($rfn)) {
|
54 |
+
(yield $key => $rfn($opts));
|
55 |
} else {
|
56 |
+
throw new \InvalidArgumentException('Each value yielded by ' . 'the iterator must be a Psr7\\Http\\Message\\RequestInterface ' . 'or a callable that returns a promise that fulfills ' . 'with a Psr7\\Message\\Http\\ResponseInterface object.');
|
57 |
}
|
58 |
}
|
59 |
};
|
60 |
+
$this->each = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\EachPromise($requests(), $config);
|
|
|
61 |
}
|
|
|
62 |
/**
|
63 |
* Get promise
|
64 |
+
*
|
65 |
+
* @return PromiseInterface
|
66 |
*/
|
67 |
+
public function promise()
|
68 |
{
|
69 |
return $this->each->promise();
|
70 |
}
|
|
|
71 |
/**
|
72 |
* Sends multiple requests concurrently and returns an array of responses
|
73 |
* and exceptions that uses the same ordering as the provided requests.
|
79 |
* @param ClientInterface $client Client used to send the requests
|
80 |
* @param array|\Iterator $requests Requests to send concurrently.
|
81 |
* @param array $options Passes through the options available in
|
82 |
+
* {@see GuzzleHttp\Pool::__construct}
|
83 |
*
|
84 |
* @return array Returns an array containing the response or an exception
|
85 |
* in the same order that the requests were sent.
|
|
|
86 |
* @throws \InvalidArgumentException if the event format is incorrect.
|
87 |
*/
|
88 |
+
public static function batch(\PixelCaffeine\Dependencies\GuzzleHttp\ClientInterface $client, $requests, array $options = [])
|
89 |
{
|
90 |
$res = [];
|
91 |
self::cmpCallback($options, 'fulfilled', $res);
|
93 |
$pool = new static($client, $requests, $options);
|
94 |
$pool->promise()->wait();
|
95 |
\ksort($res);
|
|
|
96 |
return $res;
|
97 |
}
|
|
|
98 |
/**
|
99 |
* Execute callback(s)
|
100 |
+
*
|
101 |
+
* @return void
|
102 |
*/
|
103 |
+
private static function cmpCallback(array &$options, $name, array &$results)
|
104 |
{
|
105 |
if (!isset($options[$name])) {
|
106 |
+
$options[$name] = function ($v, $k) use(&$results) {
|
107 |
$results[$k] = $v;
|
108 |
};
|
109 |
} else {
|
110 |
$currentFn = $options[$name];
|
111 |
+
$options[$name] = function ($v, $k) use(&$results, $currentFn) {
|
112 |
$currentFn($v, $k);
|
113 |
$results[$k] = $v;
|
114 |
};
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php
RENAMED
@@ -1,55 +1,49 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use GuzzleHttp\Promise\PromiseInterface;
|
6 |
-
use Psr\Http\Message\RequestInterface;
|
7 |
|
|
|
|
|
|
|
8 |
/**
|
9 |
* Prepares requests that contain a body, adding the Content-Length,
|
10 |
* Content-Type, and Expect headers.
|
11 |
-
*
|
12 |
-
* @final
|
13 |
*/
|
14 |
class PrepareBodyMiddleware
|
15 |
{
|
16 |
-
/**
|
17 |
-
* @var callable(RequestInterface, array): PromiseInterface
|
18 |
-
*/
|
19 |
private $nextHandler;
|
20 |
-
|
21 |
/**
|
22 |
-
* @param callable
|
23 |
*/
|
24 |
public function __construct(callable $nextHandler)
|
25 |
{
|
26 |
$this->nextHandler = $nextHandler;
|
27 |
}
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
{
|
31 |
$fn = $this->nextHandler;
|
32 |
-
|
33 |
// Don't do anything if the request has no body.
|
34 |
if ($request->getBody()->getSize() === 0) {
|
35 |
return $fn($request, $options);
|
36 |
}
|
37 |
-
|
38 |
$modify = [];
|
39 |
-
|
40 |
// Add a default content-type if possible.
|
41 |
if (!$request->hasHeader('Content-Type')) {
|
42 |
if ($uri = $request->getBody()->getMetadata('uri')) {
|
43 |
-
if (
|
44 |
$modify['set_headers']['Content-Type'] = $type;
|
45 |
}
|
46 |
}
|
47 |
}
|
48 |
-
|
49 |
// Add a default content-length or transfer-encoding header.
|
50 |
-
if (!$request->hasHeader('Content-Length')
|
51 |
-
&& !$request->hasHeader('Transfer-Encoding')
|
52 |
-
) {
|
53 |
$size = $request->getBody()->getSize();
|
54 |
if ($size !== null) {
|
55 |
$modify['set_headers']['Content-Length'] = $size;
|
@@ -57,46 +51,39 @@ class PrepareBodyMiddleware
|
|
57 |
$modify['set_headers']['Transfer-Encoding'] = 'chunked';
|
58 |
}
|
59 |
}
|
60 |
-
|
61 |
// Add the expect header if needed.
|
62 |
$this->addExpectHeader($request, $options, $modify);
|
63 |
-
|
64 |
-
return $fn(Psr7\Utils::modifyRequest($request, $modify), $options);
|
65 |
}
|
66 |
-
|
67 |
/**
|
68 |
* Add expect header
|
|
|
|
|
69 |
*/
|
70 |
-
private function addExpectHeader(RequestInterface $request, array $options, array &$modify)
|
71 |
{
|
72 |
// Determine if the Expect header should be used
|
73 |
if ($request->hasHeader('Expect')) {
|
74 |
return;
|
75 |
}
|
76 |
-
|
77 |
-
$expect = $options['expect'] ?? null;
|
78 |
-
|
79 |
// Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
|
80 |
-
if ($expect === false || $request->getProtocolVersion() < 1.1) {
|
81 |
return;
|
82 |
}
|
83 |
-
|
84 |
// The expect header is unconditionally enabled
|
85 |
-
if ($expect === true) {
|
86 |
$modify['set_headers']['Expect'] = '100-Continue';
|
87 |
return;
|
88 |
}
|
89 |
-
|
90 |
// By default, send the expect header when the payload is > 1mb
|
91 |
if ($expect === null) {
|
92 |
$expect = 1048576;
|
93 |
}
|
94 |
-
|
95 |
// Always add if the body cannot be rewound, the size cannot be
|
96 |
// determined, or the size is greater than the cutoff threshold
|
97 |
$body = $request->getBody();
|
98 |
$size = $body->getSize();
|
99 |
-
|
100 |
if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
|
101 |
$modify['set_headers']['Expect'] = '100-Continue';
|
102 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
8 |
/**
|
9 |
* Prepares requests that contain a body, adding the Content-Length,
|
10 |
* Content-Type, and Expect headers.
|
|
|
|
|
11 |
*/
|
12 |
class PrepareBodyMiddleware
|
13 |
{
|
14 |
+
/** @var callable */
|
|
|
|
|
15 |
private $nextHandler;
|
|
|
16 |
/**
|
17 |
+
* @param callable $nextHandler Next handler to invoke.
|
18 |
*/
|
19 |
public function __construct(callable $nextHandler)
|
20 |
{
|
21 |
$this->nextHandler = $nextHandler;
|
22 |
}
|
23 |
+
/**
|
24 |
+
* @param RequestInterface $request
|
25 |
+
* @param array $options
|
26 |
+
*
|
27 |
+
* @return PromiseInterface
|
28 |
+
*/
|
29 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
30 |
{
|
31 |
$fn = $this->nextHandler;
|
|
|
32 |
// Don't do anything if the request has no body.
|
33 |
if ($request->getBody()->getSize() === 0) {
|
34 |
return $fn($request, $options);
|
35 |
}
|
|
|
36 |
$modify = [];
|
|
|
37 |
// Add a default content-type if possible.
|
38 |
if (!$request->hasHeader('Content-Type')) {
|
39 |
if ($uri = $request->getBody()->getMetadata('uri')) {
|
40 |
+
if ($type = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\mimetype_from_filename($uri)) {
|
41 |
$modify['set_headers']['Content-Type'] = $type;
|
42 |
}
|
43 |
}
|
44 |
}
|
|
|
45 |
// Add a default content-length or transfer-encoding header.
|
46 |
+
if (!$request->hasHeader('Content-Length') && !$request->hasHeader('Transfer-Encoding')) {
|
|
|
|
|
47 |
$size = $request->getBody()->getSize();
|
48 |
if ($size !== null) {
|
49 |
$modify['set_headers']['Content-Length'] = $size;
|
51 |
$modify['set_headers']['Transfer-Encoding'] = 'chunked';
|
52 |
}
|
53 |
}
|
|
|
54 |
// Add the expect header if needed.
|
55 |
$this->addExpectHeader($request, $options, $modify);
|
56 |
+
return $fn(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\modify_request($request, $modify), $options);
|
|
|
57 |
}
|
|
|
58 |
/**
|
59 |
* Add expect header
|
60 |
+
*
|
61 |
+
* @return void
|
62 |
*/
|
63 |
+
private function addExpectHeader(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, array &$modify)
|
64 |
{
|
65 |
// Determine if the Expect header should be used
|
66 |
if ($request->hasHeader('Expect')) {
|
67 |
return;
|
68 |
}
|
69 |
+
$expect = isset($options['expect']) ? $options['expect'] : null;
|
|
|
|
|
70 |
// Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
|
71 |
+
if ($expect === \false || $request->getProtocolVersion() < 1.1) {
|
72 |
return;
|
73 |
}
|
|
|
74 |
// The expect header is unconditionally enabled
|
75 |
+
if ($expect === \true) {
|
76 |
$modify['set_headers']['Expect'] = '100-Continue';
|
77 |
return;
|
78 |
}
|
|
|
79 |
// By default, send the expect header when the payload is > 1mb
|
80 |
if ($expect === null) {
|
81 |
$expect = 1048576;
|
82 |
}
|
|
|
83 |
// Always add if the body cannot be rewound, the size cannot be
|
84 |
// determined, or the size is greater than the cutoff threshold
|
85 |
$body = $request->getBody();
|
86 |
$size = $body->getSize();
|
|
|
87 |
if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
|
88 |
$modify['set_headers']['Expect'] = '100-Continue';
|
89 |
}
|
third-party/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\BadResponseException;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\TooManyRedirectsException;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
10 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
11 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
12 |
+
/**
|
13 |
+
* Request redirect middleware.
|
14 |
+
*
|
15 |
+
* Apply this middleware like other middleware using
|
16 |
+
* {@see \GuzzleHttp\Middleware::redirect()}.
|
17 |
+
*/
|
18 |
+
class RedirectMiddleware
|
19 |
+
{
|
20 |
+
const HISTORY_HEADER = 'X-Guzzle-Redirect-History';
|
21 |
+
const STATUS_HISTORY_HEADER = 'X-Guzzle-Redirect-Status-History';
|
22 |
+
public static $defaultSettings = ['max' => 5, 'protocols' => ['http', 'https'], 'strict' => \false, 'referer' => \false, 'track_redirects' => \false];
|
23 |
+
/** @var callable */
|
24 |
+
private $nextHandler;
|
25 |
+
/**
|
26 |
+
* @param callable $nextHandler Next handler to invoke.
|
27 |
+
*/
|
28 |
+
public function __construct(callable $nextHandler)
|
29 |
+
{
|
30 |
+
$this->nextHandler = $nextHandler;
|
31 |
+
}
|
32 |
+
/**
|
33 |
+
* @param RequestInterface $request
|
34 |
+
* @param array $options
|
35 |
+
*
|
36 |
+
* @return PromiseInterface
|
37 |
+
*/
|
38 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
39 |
+
{
|
40 |
+
$fn = $this->nextHandler;
|
41 |
+
if (empty($options['allow_redirects'])) {
|
42 |
+
return $fn($request, $options);
|
43 |
+
}
|
44 |
+
if ($options['allow_redirects'] === \true) {
|
45 |
+
$options['allow_redirects'] = self::$defaultSettings;
|
46 |
+
} elseif (!\is_array($options['allow_redirects'])) {
|
47 |
+
throw new \InvalidArgumentException('allow_redirects must be true, false, or array');
|
48 |
+
} else {
|
49 |
+
// Merge the default settings with the provided settings
|
50 |
+
$options['allow_redirects'] += self::$defaultSettings;
|
51 |
+
}
|
52 |
+
if (empty($options['allow_redirects']['max'])) {
|
53 |
+
return $fn($request, $options);
|
54 |
+
}
|
55 |
+
return $fn($request, $options)->then(function (\PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response) use($request, $options) {
|
56 |
+
return $this->checkRedirect($request, $options, $response);
|
57 |
+
});
|
58 |
+
}
|
59 |
+
/**
|
60 |
+
* @param RequestInterface $request
|
61 |
+
* @param array $options
|
62 |
+
* @param ResponseInterface $response
|
63 |
+
*
|
64 |
+
* @return ResponseInterface|PromiseInterface
|
65 |
+
*/
|
66 |
+
public function checkRedirect(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response)
|
67 |
+
{
|
68 |
+
if (\substr($response->getStatusCode(), 0, 1) != '3' || !$response->hasHeader('Location')) {
|
69 |
+
return $response;
|
70 |
+
}
|
71 |
+
$this->guardMax($request, $options);
|
72 |
+
$nextRequest = $this->modifyRequest($request, $options, $response);
|
73 |
+
if (isset($options['allow_redirects']['on_redirect'])) {
|
74 |
+
\call_user_func($options['allow_redirects']['on_redirect'], $request, $response, $nextRequest->getUri());
|
75 |
+
}
|
76 |
+
/** @var PromiseInterface|ResponseInterface $promise */
|
77 |
+
$promise = $this($nextRequest, $options);
|
78 |
+
// Add headers to be able to track history of redirects.
|
79 |
+
if (!empty($options['allow_redirects']['track_redirects'])) {
|
80 |
+
return $this->withTracking($promise, (string) $nextRequest->getUri(), $response->getStatusCode());
|
81 |
+
}
|
82 |
+
return $promise;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* Enable tracking on promise.
|
86 |
+
*
|
87 |
+
* @return PromiseInterface
|
88 |
+
*/
|
89 |
+
private function withTracking(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise, $uri, $statusCode)
|
90 |
+
{
|
91 |
+
return $promise->then(function (\PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response) use($uri, $statusCode) {
|
92 |
+
// Note that we are pushing to the front of the list as this
|
93 |
+
// would be an earlier response than what is currently present
|
94 |
+
// in the history header.
|
95 |
+
$historyHeader = $response->getHeader(self::HISTORY_HEADER);
|
96 |
+
$statusHeader = $response->getHeader(self::STATUS_HISTORY_HEADER);
|
97 |
+
\array_unshift($historyHeader, $uri);
|
98 |
+
\array_unshift($statusHeader, $statusCode);
|
99 |
+
return $response->withHeader(self::HISTORY_HEADER, $historyHeader)->withHeader(self::STATUS_HISTORY_HEADER, $statusHeader);
|
100 |
+
});
|
101 |
+
}
|
102 |
+
/**
|
103 |
+
* Check for too many redirects
|
104 |
+
*
|
105 |
+
* @return void
|
106 |
+
*
|
107 |
+
* @throws TooManyRedirectsException Too many redirects.
|
108 |
+
*/
|
109 |
+
private function guardMax(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array &$options)
|
110 |
+
{
|
111 |
+
$current = isset($options['__redirect_count']) ? $options['__redirect_count'] : 0;
|
112 |
+
$options['__redirect_count'] = $current + 1;
|
113 |
+
$max = $options['allow_redirects']['max'];
|
114 |
+
if ($options['__redirect_count'] > $max) {
|
115 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\TooManyRedirectsException("Will not follow more than {$max} redirects", $request);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* @param RequestInterface $request
|
120 |
+
* @param array $options
|
121 |
+
* @param ResponseInterface $response
|
122 |
+
*
|
123 |
+
* @return RequestInterface
|
124 |
+
*/
|
125 |
+
public function modifyRequest(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response)
|
126 |
+
{
|
127 |
+
// Request modifications to apply.
|
128 |
+
$modify = [];
|
129 |
+
$protocols = $options['allow_redirects']['protocols'];
|
130 |
+
// Use a GET request if this is an entity enclosing request and we are
|
131 |
+
// not forcing RFC compliance, but rather emulating what all browsers
|
132 |
+
// would do.
|
133 |
+
$statusCode = $response->getStatusCode();
|
134 |
+
if ($statusCode == 303 || $statusCode <= 302 && !$options['allow_redirects']['strict']) {
|
135 |
+
$modify['method'] = 'GET';
|
136 |
+
$modify['body'] = '';
|
137 |
+
}
|
138 |
+
$uri = $this->redirectUri($request, $response, $protocols);
|
139 |
+
if (isset($options['idn_conversion']) && $options['idn_conversion'] !== \false) {
|
140 |
+
$idnOptions = $options['idn_conversion'] === \true ? \IDNA_DEFAULT : $options['idn_conversion'];
|
141 |
+
$uri = \PixelCaffeine\Dependencies\GuzzleHttp\Utils::idnUriConvert($uri, $idnOptions);
|
142 |
+
}
|
143 |
+
$modify['uri'] = $uri;
|
144 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\rewind_body($request);
|
145 |
+
// Add the Referer header if it is told to do so and only
|
146 |
+
// add the header if we are not redirecting from https to http.
|
147 |
+
if ($options['allow_redirects']['referer'] && $modify['uri']->getScheme() === $request->getUri()->getScheme()) {
|
148 |
+
$uri = $request->getUri()->withUserInfo('');
|
149 |
+
$modify['set_headers']['Referer'] = (string) $uri;
|
150 |
+
} else {
|
151 |
+
$modify['remove_headers'][] = 'Referer';
|
152 |
+
}
|
153 |
+
// Remove Authorization header if host is different.
|
154 |
+
if ($request->getUri()->getHost() !== $modify['uri']->getHost()) {
|
155 |
+
$modify['remove_headers'][] = 'Authorization';
|
156 |
+
}
|
157 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\modify_request($request, $modify);
|
158 |
+
}
|
159 |
+
/**
|
160 |
+
* Set the appropriate URL on the request based on the location header
|
161 |
+
*
|
162 |
+
* @param RequestInterface $request
|
163 |
+
* @param ResponseInterface $response
|
164 |
+
* @param array $protocols
|
165 |
+
*
|
166 |
+
* @return UriInterface
|
167 |
+
*/
|
168 |
+
private function redirectUri(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response, array $protocols)
|
169 |
+
{
|
170 |
+
$location = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::resolve($request->getUri(), new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Uri($response->getHeaderLine('Location')));
|
171 |
+
// Ensure that the redirect URI is allowed based on the protocols.
|
172 |
+
if (!\in_array($location->getScheme(), $protocols)) {
|
173 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\BadResponseException(\sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, \implode(', ', $protocols)), $request, $response);
|
174 |
+
}
|
175 |
+
return $location;
|
176 |
+
}
|
177 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/RequestOptions.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
|
5 |
/**
|
6 |
* This class contains a list of built-in Guzzle request options.
|
@@ -32,8 +32,7 @@ final class RequestOptions
|
|
32 |
* response that was received, and the effective URI. Any return value
|
33 |
* from the on_redirect function is ignored.
|
34 |
*/
|
35 |
-
|
36 |
-
|
37 |
/**
|
38 |
* auth: (array) Pass an array of HTTP authentication parameters to use
|
39 |
* with the request. The array must contain the username in index [0],
|
@@ -41,14 +40,12 @@ final class RequestOptions
|
|
41 |
* authentication type in index [2]. Pass null to disable authentication
|
42 |
* for a request.
|
43 |
*/
|
44 |
-
|
45 |
-
|
46 |
/**
|
47 |
* body: (resource|string|null|int|float|StreamInterface|callable|\Iterator)
|
48 |
* Body to send in the request.
|
49 |
*/
|
50 |
-
|
51 |
-
|
52 |
/**
|
53 |
* cert: (string|array) Set to a string to specify the path to a file
|
54 |
* containing a PEM formatted SSL client side certificate. If a password
|
@@ -56,43 +53,37 @@ final class RequestOptions
|
|
56 |
* file in the first array element followed by the certificate password
|
57 |
* in the second array element.
|
58 |
*/
|
59 |
-
|
60 |
-
|
61 |
/**
|
62 |
* cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
|
63 |
* Specifies whether or not cookies are used in a request or what cookie
|
64 |
* jar to use or what cookies to send. This option only works if your
|
65 |
* handler has the `cookie` middleware. Valid values are `false` and
|
66 |
-
* an instance of {@see
|
67 |
*/
|
68 |
-
|
69 |
-
|
70 |
/**
|
71 |
* connect_timeout: (float, default=0) Float describing the number of
|
72 |
* seconds to wait while trying to connect to a server. Use 0 to wait
|
73 |
* indefinitely (the default behavior).
|
74 |
*/
|
75 |
-
|
76 |
-
|
77 |
/**
|
78 |
* debug: (bool|resource) Set to true or set to a PHP stream returned by
|
79 |
* fopen() enable debug output with the HTTP handler used to send a
|
80 |
* request.
|
81 |
*/
|
82 |
-
|
83 |
-
|
84 |
/**
|
85 |
* decode_content: (bool, default=true) Specify whether or not
|
86 |
* Content-Encoding responses (gzip, deflate, etc.) are automatically
|
87 |
* decoded.
|
88 |
*/
|
89 |
-
|
90 |
-
|
91 |
/**
|
92 |
* delay: (int) The amount of time to delay before sending in milliseconds.
|
93 |
*/
|
94 |
-
|
95 |
-
|
96 |
/**
|
97 |
* expect: (bool|integer) Controls the behavior of the
|
98 |
* "Expect: 100-Continue" header.
|
@@ -109,45 +100,39 @@ final class RequestOptions
|
|
109 |
* size of the body of a request is greater than 1 MB and a request is
|
110 |
* using HTTP/1.1.
|
111 |
*/
|
112 |
-
|
113 |
-
|
114 |
/**
|
115 |
* form_params: (array) Associative array of form field names to values
|
116 |
* where each value is a string or array of strings. Sets the Content-Type
|
117 |
* header to application/x-www-form-urlencoded when no Content-Type header
|
118 |
* is already present.
|
119 |
*/
|
120 |
-
|
121 |
-
|
122 |
/**
|
123 |
* headers: (array) Associative array of HTTP headers. Each value MUST be
|
124 |
* a string or array of strings.
|
125 |
*/
|
126 |
-
|
127 |
-
|
128 |
/**
|
129 |
* http_errors: (bool, default=true) Set to false to disable exceptions
|
130 |
* when a non- successful HTTP response is received. By default,
|
131 |
* exceptions will be thrown for 4xx and 5xx responses. This option only
|
132 |
* works if your handler has the `httpErrors` middleware.
|
133 |
*/
|
134 |
-
|
135 |
-
|
136 |
/**
|
137 |
* idn: (bool|int, default=true) A combination of IDNA_* constants for
|
138 |
* idn_to_ascii() PHP's function (see "options" parameter). Set to false to
|
139 |
* disable IDN support completely, or to true to use the default
|
140 |
* configuration (IDNA_DEFAULT constant).
|
141 |
*/
|
142 |
-
|
143 |
-
|
144 |
/**
|
145 |
* json: (mixed) Adds JSON data to a request. The provided value is JSON
|
146 |
* encoded and a Content-Type header of application/json will be added to
|
147 |
* the request if no Content-Type header is already present.
|
148 |
*/
|
149 |
-
|
150 |
-
|
151 |
/**
|
152 |
* multipart: (array) Array of associative arrays, each containing a
|
153 |
* required "name" key mapping to the form field, name, a required
|
@@ -157,15 +142,13 @@ final class RequestOptions
|
|
157 |
* the part. If no "filename" key is present, then no "filename" attribute
|
158 |
* will be added to the part.
|
159 |
*/
|
160 |
-
|
161 |
-
|
162 |
/**
|
163 |
* on_headers: (callable) A callable that is invoked when the HTTP headers
|
164 |
* of the response have been received but the body has not yet begun to
|
165 |
* download.
|
166 |
*/
|
167 |
-
|
168 |
-
|
169 |
/**
|
170 |
* on_stats: (callable) allows you to get access to transfer statistics of
|
171 |
* a request and access the lower level transfer details of the handler
|
@@ -175,8 +158,7 @@ final class RequestOptions
|
|
175 |
* the error encountered. Included in the data is the total amount of time
|
176 |
* taken to send the request.
|
177 |
*/
|
178 |
-
|
179 |
-
|
180 |
/**
|
181 |
* progress: (callable) Defines a function to invoke when transfer
|
182 |
* progress is made. The function accepts the following positional
|
@@ -184,52 +166,45 @@ final class RequestOptions
|
|
184 |
* number of bytes downloaded so far, the number of bytes expected to be
|
185 |
* uploaded, the number of bytes uploaded so far.
|
186 |
*/
|
187 |
-
|
188 |
-
|
189 |
/**
|
190 |
* proxy: (string|array) Pass a string to specify an HTTP proxy, or an
|
191 |
* array to specify different proxies for different protocols (where the
|
192 |
* key is the protocol and the value is a proxy string).
|
193 |
*/
|
194 |
-
|
195 |
-
|
196 |
/**
|
197 |
* query: (array|string) Associative array of query string values to add
|
198 |
* to the request. This option uses PHP's http_build_query() to create
|
199 |
* the string representation. Pass a string value if you need more
|
200 |
* control than what this method provides
|
201 |
*/
|
202 |
-
|
203 |
-
|
204 |
/**
|
205 |
* sink: (resource|string|StreamInterface) Where the data of the
|
206 |
* response is written to. Defaults to a PHP temp stream. Providing a
|
207 |
* string will write data to a file by the given name.
|
208 |
*/
|
209 |
-
|
210 |
-
|
211 |
/**
|
212 |
* synchronous: (bool) Set to true to inform HTTP handlers that you intend
|
213 |
* on waiting on the response. This can be useful for optimizations. Note
|
214 |
* that a promise is still returned if you are using one of the async
|
215 |
* client methods.
|
216 |
*/
|
217 |
-
|
218 |
-
|
219 |
/**
|
220 |
* ssl_key: (array|string) Specify the path to a file containing a private
|
221 |
* SSL key in PEM format. If a password is required, then set to an array
|
222 |
* containing the path to the SSL key in the first array element followed
|
223 |
* by the password required for the certificate in the second element.
|
224 |
*/
|
225 |
-
|
226 |
-
|
227 |
/**
|
228 |
* stream: Set to true to attempt to stream a response rather than
|
229 |
* download it all up-front.
|
230 |
*/
|
231 |
-
|
232 |
-
|
233 |
/**
|
234 |
* verify: (bool|string, default=true) Describes the SSL certificate
|
235 |
* verification behavior of a request. Set to true to enable SSL
|
@@ -238,27 +213,23 @@ final class RequestOptions
|
|
238 |
* is insecure!). Set to a string to provide the path to a CA bundle on
|
239 |
* disk to enable verification using a custom certificate.
|
240 |
*/
|
241 |
-
|
242 |
-
|
243 |
/**
|
244 |
* timeout: (float, default=0) Float describing the timeout of the
|
245 |
* request in seconds. Use 0 to wait indefinitely (the default behavior).
|
246 |
*/
|
247 |
-
|
248 |
-
|
249 |
/**
|
250 |
* read_timeout: (float, default=default_socket_timeout ini setting) Float describing
|
251 |
* the body read timeout, for stream requests.
|
252 |
*/
|
253 |
-
|
254 |
-
|
255 |
/**
|
256 |
* version: (float) Specifies the HTTP protocol version to attempt to use.
|
257 |
*/
|
258 |
-
|
259 |
-
|
260 |
/**
|
261 |
* force_ip_resolve: (bool) Force client to use only ipv4 or ipv6 protocol
|
262 |
*/
|
263 |
-
|
264 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
|
5 |
/**
|
6 |
* This class contains a list of built-in Guzzle request options.
|
32 |
* response that was received, and the effective URI. Any return value
|
33 |
* from the on_redirect function is ignored.
|
34 |
*/
|
35 |
+
const ALLOW_REDIRECTS = 'allow_redirects';
|
|
|
36 |
/**
|
37 |
* auth: (array) Pass an array of HTTP authentication parameters to use
|
38 |
* with the request. The array must contain the username in index [0],
|
40 |
* authentication type in index [2]. Pass null to disable authentication
|
41 |
* for a request.
|
42 |
*/
|
43 |
+
const AUTH = 'auth';
|
|
|
44 |
/**
|
45 |
* body: (resource|string|null|int|float|StreamInterface|callable|\Iterator)
|
46 |
* Body to send in the request.
|
47 |
*/
|
48 |
+
const BODY = 'body';
|
|
|
49 |
/**
|
50 |
* cert: (string|array) Set to a string to specify the path to a file
|
51 |
* containing a PEM formatted SSL client side certificate. If a password
|
53 |
* file in the first array element followed by the certificate password
|
54 |
* in the second array element.
|
55 |
*/
|
56 |
+
const CERT = 'cert';
|
|
|
57 |
/**
|
58 |
* cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
|
59 |
* Specifies whether or not cookies are used in a request or what cookie
|
60 |
* jar to use or what cookies to send. This option only works if your
|
61 |
* handler has the `cookie` middleware. Valid values are `false` and
|
62 |
+
* an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}.
|
63 |
*/
|
64 |
+
const COOKIES = 'cookies';
|
|
|
65 |
/**
|
66 |
* connect_timeout: (float, default=0) Float describing the number of
|
67 |
* seconds to wait while trying to connect to a server. Use 0 to wait
|
68 |
* indefinitely (the default behavior).
|
69 |
*/
|
70 |
+
const CONNECT_TIMEOUT = 'connect_timeout';
|
|
|
71 |
/**
|
72 |
* debug: (bool|resource) Set to true or set to a PHP stream returned by
|
73 |
* fopen() enable debug output with the HTTP handler used to send a
|
74 |
* request.
|
75 |
*/
|
76 |
+
const DEBUG = 'debug';
|
|
|
77 |
/**
|
78 |
* decode_content: (bool, default=true) Specify whether or not
|
79 |
* Content-Encoding responses (gzip, deflate, etc.) are automatically
|
80 |
* decoded.
|
81 |
*/
|
82 |
+
const DECODE_CONTENT = 'decode_content';
|
|
|
83 |
/**
|
84 |
* delay: (int) The amount of time to delay before sending in milliseconds.
|
85 |
*/
|
86 |
+
const DELAY = 'delay';
|
|
|
87 |
/**
|
88 |
* expect: (bool|integer) Controls the behavior of the
|
89 |
* "Expect: 100-Continue" header.
|
100 |
* size of the body of a request is greater than 1 MB and a request is
|
101 |
* using HTTP/1.1.
|
102 |
*/
|
103 |
+
const EXPECT = 'expect';
|
|
|
104 |
/**
|
105 |
* form_params: (array) Associative array of form field names to values
|
106 |
* where each value is a string or array of strings. Sets the Content-Type
|
107 |
* header to application/x-www-form-urlencoded when no Content-Type header
|
108 |
* is already present.
|
109 |
*/
|
110 |
+
const FORM_PARAMS = 'form_params';
|
|
|
111 |
/**
|
112 |
* headers: (array) Associative array of HTTP headers. Each value MUST be
|
113 |
* a string or array of strings.
|
114 |
*/
|
115 |
+
const HEADERS = 'headers';
|
|
|
116 |
/**
|
117 |
* http_errors: (bool, default=true) Set to false to disable exceptions
|
118 |
* when a non- successful HTTP response is received. By default,
|
119 |
* exceptions will be thrown for 4xx and 5xx responses. This option only
|
120 |
* works if your handler has the `httpErrors` middleware.
|
121 |
*/
|
122 |
+
const HTTP_ERRORS = 'http_errors';
|
|
|
123 |
/**
|
124 |
* idn: (bool|int, default=true) A combination of IDNA_* constants for
|
125 |
* idn_to_ascii() PHP's function (see "options" parameter). Set to false to
|
126 |
* disable IDN support completely, or to true to use the default
|
127 |
* configuration (IDNA_DEFAULT constant).
|
128 |
*/
|
129 |
+
const IDN_CONVERSION = 'idn_conversion';
|
|
|
130 |
/**
|
131 |
* json: (mixed) Adds JSON data to a request. The provided value is JSON
|
132 |
* encoded and a Content-Type header of application/json will be added to
|
133 |
* the request if no Content-Type header is already present.
|
134 |
*/
|
135 |
+
const JSON = 'json';
|
|
|
136 |
/**
|
137 |
* multipart: (array) Array of associative arrays, each containing a
|
138 |
* required "name" key mapping to the form field, name, a required
|
142 |
* the part. If no "filename" key is present, then no "filename" attribute
|
143 |
* will be added to the part.
|
144 |
*/
|
145 |
+
const MULTIPART = 'multipart';
|
|
|
146 |
/**
|
147 |
* on_headers: (callable) A callable that is invoked when the HTTP headers
|
148 |
* of the response have been received but the body has not yet begun to
|
149 |
* download.
|
150 |
*/
|
151 |
+
const ON_HEADERS = 'on_headers';
|
|
|
152 |
/**
|
153 |
* on_stats: (callable) allows you to get access to transfer statistics of
|
154 |
* a request and access the lower level transfer details of the handler
|
158 |
* the error encountered. Included in the data is the total amount of time
|
159 |
* taken to send the request.
|
160 |
*/
|
161 |
+
const ON_STATS = 'on_stats';
|
|
|
162 |
/**
|
163 |
* progress: (callable) Defines a function to invoke when transfer
|
164 |
* progress is made. The function accepts the following positional
|
166 |
* number of bytes downloaded so far, the number of bytes expected to be
|
167 |
* uploaded, the number of bytes uploaded so far.
|
168 |
*/
|
169 |
+
const PROGRESS = 'progress';
|
|
|
170 |
/**
|
171 |
* proxy: (string|array) Pass a string to specify an HTTP proxy, or an
|
172 |
* array to specify different proxies for different protocols (where the
|
173 |
* key is the protocol and the value is a proxy string).
|
174 |
*/
|
175 |
+
const PROXY = 'proxy';
|
|
|
176 |
/**
|
177 |
* query: (array|string) Associative array of query string values to add
|
178 |
* to the request. This option uses PHP's http_build_query() to create
|
179 |
* the string representation. Pass a string value if you need more
|
180 |
* control than what this method provides
|
181 |
*/
|
182 |
+
const QUERY = 'query';
|
|
|
183 |
/**
|
184 |
* sink: (resource|string|StreamInterface) Where the data of the
|
185 |
* response is written to. Defaults to a PHP temp stream. Providing a
|
186 |
* string will write data to a file by the given name.
|
187 |
*/
|
188 |
+
const SINK = 'sink';
|
|
|
189 |
/**
|
190 |
* synchronous: (bool) Set to true to inform HTTP handlers that you intend
|
191 |
* on waiting on the response. This can be useful for optimizations. Note
|
192 |
* that a promise is still returned if you are using one of the async
|
193 |
* client methods.
|
194 |
*/
|
195 |
+
const SYNCHRONOUS = 'synchronous';
|
|
|
196 |
/**
|
197 |
* ssl_key: (array|string) Specify the path to a file containing a private
|
198 |
* SSL key in PEM format. If a password is required, then set to an array
|
199 |
* containing the path to the SSL key in the first array element followed
|
200 |
* by the password required for the certificate in the second element.
|
201 |
*/
|
202 |
+
const SSL_KEY = 'ssl_key';
|
|
|
203 |
/**
|
204 |
* stream: Set to true to attempt to stream a response rather than
|
205 |
* download it all up-front.
|
206 |
*/
|
207 |
+
const STREAM = 'stream';
|
|
|
208 |
/**
|
209 |
* verify: (bool|string, default=true) Describes the SSL certificate
|
210 |
* verification behavior of a request. Set to true to enable SSL
|
213 |
* is insecure!). Set to a string to provide the path to a CA bundle on
|
214 |
* disk to enable verification using a custom certificate.
|
215 |
*/
|
216 |
+
const VERIFY = 'verify';
|
|
|
217 |
/**
|
218 |
* timeout: (float, default=0) Float describing the timeout of the
|
219 |
* request in seconds. Use 0 to wait indefinitely (the default behavior).
|
220 |
*/
|
221 |
+
const TIMEOUT = 'timeout';
|
|
|
222 |
/**
|
223 |
* read_timeout: (float, default=default_socket_timeout ini setting) Float describing
|
224 |
* the body read timeout, for stream requests.
|
225 |
*/
|
226 |
+
const READ_TIMEOUT = 'read_timeout';
|
|
|
227 |
/**
|
228 |
* version: (float) Specifies the HTTP protocol version to attempt to use.
|
229 |
*/
|
230 |
+
const VERSION = 'version';
|
|
|
231 |
/**
|
232 |
* force_ip_resolve: (bool) Force client to use only ipv4 or ipv6 protocol
|
233 |
*/
|
234 |
+
const FORCE_IP_RESOLVE = 'force_ip_resolve';
|
235 |
}
|
third-party/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectedPromise;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
10 |
+
/**
|
11 |
+
* Middleware that retries requests based on the boolean result of
|
12 |
+
* invoking the provided "decider" function.
|
13 |
+
*/
|
14 |
+
class RetryMiddleware
|
15 |
+
{
|
16 |
+
/** @var callable */
|
17 |
+
private $nextHandler;
|
18 |
+
/** @var callable */
|
19 |
+
private $decider;
|
20 |
+
/** @var callable */
|
21 |
+
private $delay;
|
22 |
+
/**
|
23 |
+
* @param callable $decider Function that accepts the number of retries,
|
24 |
+
* a request, [response], and [exception] and
|
25 |
+
* returns true if the request is to be
|
26 |
+
* retried.
|
27 |
+
* @param callable $nextHandler Next handler to invoke.
|
28 |
+
* @param callable $delay Function that accepts the number of retries
|
29 |
+
* and [response] and returns the number of
|
30 |
+
* milliseconds to delay.
|
31 |
+
*/
|
32 |
+
public function __construct(callable $decider, callable $nextHandler, callable $delay = null)
|
33 |
+
{
|
34 |
+
$this->decider = $decider;
|
35 |
+
$this->nextHandler = $nextHandler;
|
36 |
+
$this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* Default exponential backoff delay function.
|
40 |
+
*
|
41 |
+
* @param int $retries
|
42 |
+
*
|
43 |
+
* @return int milliseconds.
|
44 |
+
*/
|
45 |
+
public static function exponentialDelay($retries)
|
46 |
+
{
|
47 |
+
return (int) \pow(2, $retries - 1) * 1000;
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* @param RequestInterface $request
|
51 |
+
* @param array $options
|
52 |
+
*
|
53 |
+
* @return PromiseInterface
|
54 |
+
*/
|
55 |
+
public function __invoke(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options)
|
56 |
+
{
|
57 |
+
if (!isset($options['retries'])) {
|
58 |
+
$options['retries'] = 0;
|
59 |
+
}
|
60 |
+
$fn = $this->nextHandler;
|
61 |
+
return $fn($request, $options)->then($this->onFulfilled($request, $options), $this->onRejected($request, $options));
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* Execute fulfilled closure
|
65 |
+
*
|
66 |
+
* @return mixed
|
67 |
+
*/
|
68 |
+
private function onFulfilled(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $req, array $options)
|
69 |
+
{
|
70 |
+
return function ($value) use($req, $options) {
|
71 |
+
if (!\call_user_func($this->decider, $options['retries'], $req, $value, null)) {
|
72 |
+
return $value;
|
73 |
+
}
|
74 |
+
return $this->doRetry($req, $options, $value);
|
75 |
+
};
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* Execute rejected closure
|
79 |
+
*
|
80 |
+
* @return callable
|
81 |
+
*/
|
82 |
+
private function onRejected(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $req, array $options)
|
83 |
+
{
|
84 |
+
return function ($reason) use($req, $options) {
|
85 |
+
if (!\call_user_func($this->decider, $options['retries'], $req, null, $reason)) {
|
86 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\rejection_for($reason);
|
87 |
+
}
|
88 |
+
return $this->doRetry($req, $options);
|
89 |
+
};
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* @return self
|
93 |
+
*/
|
94 |
+
private function doRetry(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, array $options, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null)
|
95 |
+
{
|
96 |
+
$options['delay'] = \call_user_func($this->delay, ++$options['retries'], $response);
|
97 |
+
return $this($request, $options);
|
98 |
+
}
|
99 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/guzzle/src/TransferStats.php
RENAMED
@@ -1,42 +1,21 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp;
|
4 |
-
|
5 |
-
use Psr\Http\Message\RequestInterface;
|
6 |
-
use Psr\Http\Message\ResponseInterface;
|
7 |
-
use Psr\Http\Message\UriInterface;
|
8 |
|
|
|
|
|
|
|
9 |
/**
|
10 |
* Represents data at the point after it was transferred either successfully
|
11 |
* or after a network error.
|
12 |
*/
|
13 |
final class TransferStats
|
14 |
{
|
15 |
-
/**
|
16 |
-
* @var RequestInterface
|
17 |
-
*/
|
18 |
private $request;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var ResponseInterface|null
|
22 |
-
*/
|
23 |
private $response;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var float|null
|
27 |
-
*/
|
28 |
private $transferTime;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var array
|
32 |
-
*/
|
33 |
private $handlerStats;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var mixed|null
|
37 |
-
*/
|
38 |
private $handlerErrorData;
|
39 |
-
|
40 |
/**
|
41 |
* @param RequestInterface $request Request that was sent.
|
42 |
* @param ResponseInterface|null $response Response received (if any)
|
@@ -44,41 +23,39 @@ final class TransferStats
|
|
44 |
* @param mixed $handlerErrorData Handler error data.
|
45 |
* @param array $handlerStats Handler specific stats.
|
46 |
*/
|
47 |
-
public function __construct(
|
48 |
-
|
49 |
-
?ResponseInterface $response = null,
|
50 |
-
?float $transferTime = null,
|
51 |
-
$handlerErrorData = null,
|
52 |
-
array $handlerStats = []
|
53 |
-
) {
|
54 |
$this->request = $request;
|
55 |
$this->response = $response;
|
56 |
$this->transferTime = $transferTime;
|
57 |
$this->handlerErrorData = $handlerErrorData;
|
58 |
$this->handlerStats = $handlerStats;
|
59 |
}
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
{
|
63 |
return $this->request;
|
64 |
}
|
65 |
-
|
66 |
/**
|
67 |
* Returns the response that was received (if any).
|
|
|
|
|
68 |
*/
|
69 |
-
public function getResponse()
|
70 |
{
|
71 |
return $this->response;
|
72 |
}
|
73 |
-
|
74 |
/**
|
75 |
* Returns true if a response was received.
|
|
|
|
|
76 |
*/
|
77 |
-
public function hasResponse()
|
78 |
{
|
79 |
return $this->response !== null;
|
80 |
}
|
81 |
-
|
82 |
/**
|
83 |
* Gets handler specific error data.
|
84 |
*
|
@@ -92,33 +69,33 @@ final class TransferStats
|
|
92 |
{
|
93 |
return $this->handlerErrorData;
|
94 |
}
|
95 |
-
|
96 |
/**
|
97 |
* Get the effective URI the request was sent to.
|
|
|
|
|
98 |
*/
|
99 |
-
public function getEffectiveUri()
|
100 |
{
|
101 |
return $this->request->getUri();
|
102 |
}
|
103 |
-
|
104 |
/**
|
105 |
* Get the estimated time the request was being transferred by the handler.
|
106 |
*
|
107 |
* @return float|null Time in seconds.
|
108 |
*/
|
109 |
-
public function getTransferTime()
|
110 |
{
|
111 |
return $this->transferTime;
|
112 |
}
|
113 |
-
|
114 |
/**
|
115 |
* Gets an array of all of the handler specific transfer data.
|
|
|
|
|
116 |
*/
|
117 |
-
public function getHandlerStats()
|
118 |
{
|
119 |
return $this->handlerStats;
|
120 |
}
|
121 |
-
|
122 |
/**
|
123 |
* Get a specific handler statistic from the handler by name.
|
124 |
*
|
@@ -126,7 +103,7 @@ final class TransferStats
|
|
126 |
*
|
127 |
* @return mixed|null
|
128 |
*/
|
129 |
-
public function getHandlerStat(
|
130 |
{
|
131 |
return isset($this->handlerStats[$stat]) ? $this->handlerStats[$stat] : null;
|
132 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
8 |
/**
|
9 |
* Represents data at the point after it was transferred either successfully
|
10 |
* or after a network error.
|
11 |
*/
|
12 |
final class TransferStats
|
13 |
{
|
|
|
|
|
|
|
14 |
private $request;
|
|
|
|
|
|
|
|
|
15 |
private $response;
|
|
|
|
|
|
|
|
|
16 |
private $transferTime;
|
|
|
|
|
|
|
|
|
17 |
private $handlerStats;
|
|
|
|
|
|
|
|
|
18 |
private $handlerErrorData;
|
|
|
19 |
/**
|
20 |
* @param RequestInterface $request Request that was sent.
|
21 |
* @param ResponseInterface|null $response Response received (if any)
|
23 |
* @param mixed $handlerErrorData Handler error data.
|
24 |
* @param array $handlerStats Handler specific stats.
|
25 |
*/
|
26 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface $request, \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface $response = null, $transferTime = null, $handlerErrorData = null, $handlerStats = [])
|
27 |
+
{
|
|
|
|
|
|
|
|
|
|
|
28 |
$this->request = $request;
|
29 |
$this->response = $response;
|
30 |
$this->transferTime = $transferTime;
|
31 |
$this->handlerErrorData = $handlerErrorData;
|
32 |
$this->handlerStats = $handlerStats;
|
33 |
}
|
34 |
+
/**
|
35 |
+
* @return RequestInterface
|
36 |
+
*/
|
37 |
+
public function getRequest()
|
38 |
{
|
39 |
return $this->request;
|
40 |
}
|
|
|
41 |
/**
|
42 |
* Returns the response that was received (if any).
|
43 |
+
*
|
44 |
+
* @return ResponseInterface|null
|
45 |
*/
|
46 |
+
public function getResponse()
|
47 |
{
|
48 |
return $this->response;
|
49 |
}
|
|
|
50 |
/**
|
51 |
* Returns true if a response was received.
|
52 |
+
*
|
53 |
+
* @return bool
|
54 |
*/
|
55 |
+
public function hasResponse()
|
56 |
{
|
57 |
return $this->response !== null;
|
58 |
}
|
|
|
59 |
/**
|
60 |
* Gets handler specific error data.
|
61 |
*
|
69 |
{
|
70 |
return $this->handlerErrorData;
|
71 |
}
|
|
|
72 |
/**
|
73 |
* Get the effective URI the request was sent to.
|
74 |
+
*
|
75 |
+
* @return UriInterface
|
76 |
*/
|
77 |
+
public function getEffectiveUri()
|
78 |
{
|
79 |
return $this->request->getUri();
|
80 |
}
|
|
|
81 |
/**
|
82 |
* Get the estimated time the request was being transferred by the handler.
|
83 |
*
|
84 |
* @return float|null Time in seconds.
|
85 |
*/
|
86 |
+
public function getTransferTime()
|
87 |
{
|
88 |
return $this->transferTime;
|
89 |
}
|
|
|
90 |
/**
|
91 |
* Gets an array of all of the handler specific transfer data.
|
92 |
+
*
|
93 |
+
* @return array
|
94 |
*/
|
95 |
+
public function getHandlerStats()
|
96 |
{
|
97 |
return $this->handlerStats;
|
98 |
}
|
|
|
99 |
/**
|
100 |
* Get a specific handler statistic from the handler by name.
|
101 |
*
|
103 |
*
|
104 |
* @return mixed|null
|
105 |
*/
|
106 |
+
public function getHandlerStat($stat)
|
107 |
{
|
108 |
return isset($this->handlerStats[$stat]) ? $this->handlerStats[$stat] : null;
|
109 |
}
|
third-party/vendor/guzzlehttp/guzzle/src/UriTemplate.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Expands URI templates. Userland implementation of PECL uri_template.
|
7 |
+
*
|
8 |
+
* @link http://tools.ietf.org/html/rfc6570
|
9 |
+
*/
|
10 |
+
class UriTemplate
|
11 |
+
{
|
12 |
+
/** @var string URI template */
|
13 |
+
private $template;
|
14 |
+
/** @var array Variables to use in the template expansion */
|
15 |
+
private $variables;
|
16 |
+
/** @var array Hash for quick operator lookups */
|
17 |
+
private static $operatorHash = ['' => ['prefix' => '', 'joiner' => ',', 'query' => \false], '+' => ['prefix' => '', 'joiner' => ',', 'query' => \false], '#' => ['prefix' => '#', 'joiner' => ',', 'query' => \false], '.' => ['prefix' => '.', 'joiner' => '.', 'query' => \false], '/' => ['prefix' => '/', 'joiner' => '/', 'query' => \false], ';' => ['prefix' => ';', 'joiner' => ';', 'query' => \true], '?' => ['prefix' => '?', 'joiner' => '&', 'query' => \true], '&' => ['prefix' => '&', 'joiner' => '&', 'query' => \true]];
|
18 |
+
/** @var array Delimiters */
|
19 |
+
private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '='];
|
20 |
+
/** @var array Percent encoded delimiters */
|
21 |
+
private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%3B', '%3D'];
|
22 |
+
public function expand($template, array $variables)
|
23 |
+
{
|
24 |
+
if (\false === \strpos($template, '{')) {
|
25 |
+
return $template;
|
26 |
+
}
|
27 |
+
$this->template = $template;
|
28 |
+
$this->variables = $variables;
|
29 |
+
return \preg_replace_callback('/\\{([^\\}]+)\\}/', [$this, 'expandMatch'], $this->template);
|
30 |
+
}
|
31 |
+
/**
|
32 |
+
* Parse an expression into parts
|
33 |
+
*
|
34 |
+
* @param string $expression Expression to parse
|
35 |
+
*
|
36 |
+
* @return array Returns an associative array of parts
|
37 |
+
*/
|
38 |
+
private function parseExpression($expression)
|
39 |
+
{
|
40 |
+
$result = [];
|
41 |
+
if (isset(self::$operatorHash[$expression[0]])) {
|
42 |
+
$result['operator'] = $expression[0];
|
43 |
+
$expression = \substr($expression, 1);
|
44 |
+
} else {
|
45 |
+
$result['operator'] = '';
|
46 |
+
}
|
47 |
+
foreach (\explode(',', $expression) as $value) {
|
48 |
+
$value = \trim($value);
|
49 |
+
$varspec = [];
|
50 |
+
if ($colonPos = \strpos($value, ':')) {
|
51 |
+
$varspec['value'] = \substr($value, 0, $colonPos);
|
52 |
+
$varspec['modifier'] = ':';
|
53 |
+
$varspec['position'] = (int) \substr($value, $colonPos + 1);
|
54 |
+
} elseif (\substr($value, -1) === '*') {
|
55 |
+
$varspec['modifier'] = '*';
|
56 |
+
$varspec['value'] = \substr($value, 0, -1);
|
57 |
+
} else {
|
58 |
+
$varspec['value'] = (string) $value;
|
59 |
+
$varspec['modifier'] = '';
|
60 |
+
}
|
61 |
+
$result['values'][] = $varspec;
|
62 |
+
}
|
63 |
+
return $result;
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* Process an expansion
|
67 |
+
*
|
68 |
+
* @param array $matches Matches met in the preg_replace_callback
|
69 |
+
*
|
70 |
+
* @return string Returns the replacement string
|
71 |
+
*/
|
72 |
+
private function expandMatch(array $matches)
|
73 |
+
{
|
74 |
+
static $rfc1738to3986 = ['+' => '%20', '%7e' => '~'];
|
75 |
+
$replacements = [];
|
76 |
+
$parsed = self::parseExpression($matches[1]);
|
77 |
+
$prefix = self::$operatorHash[$parsed['operator']]['prefix'];
|
78 |
+
$joiner = self::$operatorHash[$parsed['operator']]['joiner'];
|
79 |
+
$useQuery = self::$operatorHash[$parsed['operator']]['query'];
|
80 |
+
foreach ($parsed['values'] as $value) {
|
81 |
+
if (!isset($this->variables[$value['value']])) {
|
82 |
+
continue;
|
83 |
+
}
|
84 |
+
$variable = $this->variables[$value['value']];
|
85 |
+
$actuallyUseQuery = $useQuery;
|
86 |
+
$expanded = '';
|
87 |
+
if (\is_array($variable)) {
|
88 |
+
$isAssoc = $this->isAssoc($variable);
|
89 |
+
$kvp = [];
|
90 |
+
foreach ($variable as $key => $var) {
|
91 |
+
if ($isAssoc) {
|
92 |
+
$key = \rawurlencode($key);
|
93 |
+
$isNestedArray = \is_array($var);
|
94 |
+
} else {
|
95 |
+
$isNestedArray = \false;
|
96 |
+
}
|
97 |
+
if (!$isNestedArray) {
|
98 |
+
$var = \rawurlencode($var);
|
99 |
+
if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
|
100 |
+
$var = $this->decodeReserved($var);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
if ($value['modifier'] === '*') {
|
104 |
+
if ($isAssoc) {
|
105 |
+
if ($isNestedArray) {
|
106 |
+
// Nested arrays must allow for deeply nested
|
107 |
+
// structures.
|
108 |
+
$var = \strtr(\http_build_query([$key => $var]), $rfc1738to3986);
|
109 |
+
} else {
|
110 |
+
$var = $key . '=' . $var;
|
111 |
+
}
|
112 |
+
} elseif ($key > 0 && $actuallyUseQuery) {
|
113 |
+
$var = $value['value'] . '=' . $var;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
$kvp[$key] = $var;
|
117 |
+
}
|
118 |
+
if (empty($variable)) {
|
119 |
+
$actuallyUseQuery = \false;
|
120 |
+
} elseif ($value['modifier'] === '*') {
|
121 |
+
$expanded = \implode($joiner, $kvp);
|
122 |
+
if ($isAssoc) {
|
123 |
+
// Don't prepend the value name when using the explode
|
124 |
+
// modifier with an associative array.
|
125 |
+
$actuallyUseQuery = \false;
|
126 |
+
}
|
127 |
+
} else {
|
128 |
+
if ($isAssoc) {
|
129 |
+
// When an associative array is encountered and the
|
130 |
+
// explode modifier is not set, then the result must be
|
131 |
+
// a comma separated list of keys followed by their
|
132 |
+
// respective values.
|
133 |
+
foreach ($kvp as $k => &$v) {
|
134 |
+
$v = $k . ',' . $v;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
$expanded = \implode(',', $kvp);
|
138 |
+
}
|
139 |
+
} else {
|
140 |
+
if ($value['modifier'] === ':') {
|
141 |
+
$variable = \substr($variable, 0, $value['position']);
|
142 |
+
}
|
143 |
+
$expanded = \rawurlencode($variable);
|
144 |
+
if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
|
145 |
+
$expanded = $this->decodeReserved($expanded);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
if ($actuallyUseQuery) {
|
149 |
+
if (!$expanded && $joiner !== '&') {
|
150 |
+
$expanded = $value['value'];
|
151 |
+
} else {
|
152 |
+
$expanded = $value['value'] . '=' . $expanded;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
$replacements[] = $expanded;
|
156 |
+
}
|
157 |
+
$ret = \implode($joiner, $replacements);
|
158 |
+
if ($ret && $prefix) {
|
159 |
+
return $prefix . $ret;
|
160 |
+
}
|
161 |
+
return $ret;
|
162 |
+
}
|
163 |
+
/**
|
164 |
+
* Determines if an array is associative.
|
165 |
+
*
|
166 |
+
* This makes the assumption that input arrays are sequences or hashes.
|
167 |
+
* This assumption is a tradeoff for accuracy in favor of speed, but it
|
168 |
+
* should work in almost every case where input is supplied for a URI
|
169 |
+
* template.
|
170 |
+
*
|
171 |
+
* @param array $array Array to check
|
172 |
+
*
|
173 |
+
* @return bool
|
174 |
+
*/
|
175 |
+
private function isAssoc(array $array)
|
176 |
+
{
|
177 |
+
return $array && \array_keys($array)[0] !== 0;
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* Removes percent encoding on reserved characters (used with + and #
|
181 |
+
* modifiers).
|
182 |
+
*
|
183 |
+
* @param string $string String to fix
|
184 |
+
*
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
private function decodeReserved($string)
|
188 |
+
{
|
189 |
+
return \str_replace(self::$delimsPct, self::$delims, $string);
|
190 |
+
}
|
191 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/Utils.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Exception\InvalidArgumentException;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Symfony\Polyfill\Intl\Idn\Idn;
|
8 |
+
final class Utils
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Wrapper for the hrtime() or microtime() functions
|
12 |
+
* (depending on the PHP version, one of the two is used)
|
13 |
+
*
|
14 |
+
* @return float|mixed UNIX timestamp
|
15 |
+
*
|
16 |
+
* @internal
|
17 |
+
*/
|
18 |
+
public static function currentTime()
|
19 |
+
{
|
20 |
+
return \function_exists('hrtime') ? \hrtime(\true) / 1000000000.0 : \microtime(\true);
|
21 |
+
}
|
22 |
+
/**
|
23 |
+
* @param int $options
|
24 |
+
*
|
25 |
+
* @return UriInterface
|
26 |
+
* @throws InvalidArgumentException
|
27 |
+
*
|
28 |
+
* @internal
|
29 |
+
*/
|
30 |
+
public static function idnUriConvert(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, $options = 0)
|
31 |
+
{
|
32 |
+
if ($uri->getHost()) {
|
33 |
+
$asciiHost = self::idnToAsci($uri->getHost(), $options, $info);
|
34 |
+
if ($asciiHost === \false) {
|
35 |
+
$errorBitSet = isset($info['errors']) ? $info['errors'] : 0;
|
36 |
+
$errorConstants = \array_filter(\array_keys(\get_defined_constants()), function ($name) {
|
37 |
+
return \substr($name, 0, 11) === 'IDNA_ERROR_';
|
38 |
+
});
|
39 |
+
$errors = [];
|
40 |
+
foreach ($errorConstants as $errorConstant) {
|
41 |
+
if ($errorBitSet & \constant($errorConstant)) {
|
42 |
+
$errors[] = $errorConstant;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
$errorMessage = 'IDN conversion failed';
|
46 |
+
if ($errors) {
|
47 |
+
$errorMessage .= ' (errors: ' . \implode(', ', $errors) . ')';
|
48 |
+
}
|
49 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\InvalidArgumentException($errorMessage);
|
50 |
+
} else {
|
51 |
+
if ($uri->getHost() !== $asciiHost) {
|
52 |
+
// Replace URI only if the ASCII version is different
|
53 |
+
$uri = $uri->withHost($asciiHost);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
return $uri;
|
58 |
+
}
|
59 |
+
/**
|
60 |
+
* @param string $domain
|
61 |
+
* @param int $options
|
62 |
+
* @param array $info
|
63 |
+
*
|
64 |
+
* @return string|false
|
65 |
+
*/
|
66 |
+
private static function idnToAsci($domain, $options, &$info = [])
|
67 |
+
{
|
68 |
+
if (\preg_match('%^[ -~]+$%', $domain) === 1) {
|
69 |
+
return $domain;
|
70 |
+
}
|
71 |
+
if (\extension_loaded('intl') && \defined('INTL_IDNA_VARIANT_UTS46')) {
|
72 |
+
return \idn_to_ascii($domain, $options, \INTL_IDNA_VARIANT_UTS46, $info);
|
73 |
+
}
|
74 |
+
/*
|
75 |
+
* The Idn class is marked as @internal. Verify that class and method exists.
|
76 |
+
*/
|
77 |
+
if (\method_exists(\PixelCaffeine\Dependencies\Symfony\Polyfill\Intl\Idn\Idn::class, 'idn_to_ascii')) {
|
78 |
+
return \PixelCaffeine\Dependencies\Symfony\Polyfill\Intl\Idn\Idn::idn_to_ascii($domain, $options, \PixelCaffeine\Dependencies\Symfony\Polyfill\Intl\Idn\Idn::INTL_IDNA_VARIANT_UTS46, $info);
|
79 |
+
}
|
80 |
+
throw new \RuntimeException('ext-intl or symfony/polyfill-intl-idn not loaded or too old');
|
81 |
+
}
|
82 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/functions.php
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlHandler;
|
6 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlMultiHandler;
|
7 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Handler\Proxy;
|
8 |
+
use PixelCaffeine\Dependencies\GuzzleHttp\Handler\StreamHandler;
|
9 |
+
/**
|
10 |
+
* Expands a URI template
|
11 |
+
*
|
12 |
+
* @param string $template URI template
|
13 |
+
* @param array $variables Template variables
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
function uri_template($template, array $variables)
|
18 |
+
{
|
19 |
+
if (\extension_loaded('uri_template')) {
|
20 |
+
// @codeCoverageIgnoreStart
|
21 |
+
return \PixelCaffeine\Dependencies\uri_template($template, $variables);
|
22 |
+
// @codeCoverageIgnoreEnd
|
23 |
+
}
|
24 |
+
static $uriTemplate;
|
25 |
+
if (!$uriTemplate) {
|
26 |
+
$uriTemplate = new \PixelCaffeine\Dependencies\GuzzleHttp\UriTemplate();
|
27 |
+
}
|
28 |
+
return $uriTemplate->expand($template, $variables);
|
29 |
+
}
|
30 |
+
/**
|
31 |
+
* Debug function used to describe the provided value type and class.
|
32 |
+
*
|
33 |
+
* @param mixed $input
|
34 |
+
*
|
35 |
+
* @return string Returns a string containing the type of the variable and
|
36 |
+
* if a class is provided, the class name.
|
37 |
+
*/
|
38 |
+
function describe_type($input)
|
39 |
+
{
|
40 |
+
switch (\gettype($input)) {
|
41 |
+
case 'object':
|
42 |
+
return 'object(' . \get_class($input) . ')';
|
43 |
+
case 'array':
|
44 |
+
return 'array(' . \count($input) . ')';
|
45 |
+
default:
|
46 |
+
\ob_start();
|
47 |
+
\var_dump($input);
|
48 |
+
// normalize float vs double
|
49 |
+
return \str_replace('double(', 'float(', \rtrim(\ob_get_clean()));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* Parses an array of header lines into an associative array of headers.
|
54 |
+
*
|
55 |
+
* @param iterable $lines Header lines array of strings in the following
|
56 |
+
* format: "Name: Value"
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
function headers_from_lines($lines)
|
60 |
+
{
|
61 |
+
$headers = [];
|
62 |
+
foreach ($lines as $line) {
|
63 |
+
$parts = \explode(':', $line, 2);
|
64 |
+
$headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null;
|
65 |
+
}
|
66 |
+
return $headers;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* Returns a debug stream based on the provided variable.
|
70 |
+
*
|
71 |
+
* @param mixed $value Optional value
|
72 |
+
*
|
73 |
+
* @return resource
|
74 |
+
*/
|
75 |
+
function debug_resource($value = null)
|
76 |
+
{
|
77 |
+
if (\is_resource($value)) {
|
78 |
+
return $value;
|
79 |
+
} elseif (\defined('STDOUT')) {
|
80 |
+
return \STDOUT;
|
81 |
+
}
|
82 |
+
return \fopen('php://output', 'w');
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* Chooses and creates a default handler to use based on the environment.
|
86 |
+
*
|
87 |
+
* The returned handler is not wrapped by any default middlewares.
|
88 |
+
*
|
89 |
+
* @return callable Returns the best handler for the given system.
|
90 |
+
* @throws \RuntimeException if no viable Handler is available.
|
91 |
+
*/
|
92 |
+
function choose_handler()
|
93 |
+
{
|
94 |
+
$handler = null;
|
95 |
+
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
|
96 |
+
$handler = \PixelCaffeine\Dependencies\GuzzleHttp\Handler\Proxy::wrapSync(new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlMultiHandler(), new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlHandler());
|
97 |
+
} elseif (\function_exists('curl_exec')) {
|
98 |
+
$handler = new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlHandler();
|
99 |
+
} elseif (\function_exists('curl_multi_exec')) {
|
100 |
+
$handler = new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\CurlMultiHandler();
|
101 |
+
}
|
102 |
+
if (\ini_get('allow_url_fopen')) {
|
103 |
+
$handler = $handler ? \PixelCaffeine\Dependencies\GuzzleHttp\Handler\Proxy::wrapStreaming($handler, new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\StreamHandler()) : new \PixelCaffeine\Dependencies\GuzzleHttp\Handler\StreamHandler();
|
104 |
+
} elseif (!$handler) {
|
105 |
+
throw new \RuntimeException('GuzzleHttp requires cURL, the ' . 'allow_url_fopen ini setting, or a custom HTTP handler.');
|
106 |
+
}
|
107 |
+
return $handler;
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* Get the default User-Agent string to use with Guzzle
|
111 |
+
*
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
function default_user_agent()
|
115 |
+
{
|
116 |
+
static $defaultAgent = '';
|
117 |
+
if (!$defaultAgent) {
|
118 |
+
$defaultAgent = 'GuzzleHttp/' . \PixelCaffeine\Dependencies\GuzzleHttp\Client::VERSION;
|
119 |
+
if (\extension_loaded('curl') && \function_exists('curl_version')) {
|
120 |
+
$defaultAgent .= ' curl/' . \curl_version()['version'];
|
121 |
+
}
|
122 |
+
$defaultAgent .= ' PHP/' . \PHP_VERSION;
|
123 |
+
}
|
124 |
+
return $defaultAgent;
|
125 |
+
}
|
126 |
+
/**
|
127 |
+
* Returns the default cacert bundle for the current system.
|
128 |
+
*
|
129 |
+
* First, the openssl.cafile and curl.cainfo php.ini settings are checked.
|
130 |
+
* If those settings are not configured, then the common locations for
|
131 |
+
* bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
|
132 |
+
* and Windows are checked. If any of these file locations are found on
|
133 |
+
* disk, they will be utilized.
|
134 |
+
*
|
135 |
+
* Note: the result of this function is cached for subsequent calls.
|
136 |
+
*
|
137 |
+
* @return string
|
138 |
+
* @throws \RuntimeException if no bundle can be found.
|
139 |
+
*/
|
140 |
+
function default_ca_bundle()
|
141 |
+
{
|
142 |
+
static $cached = null;
|
143 |
+
static $cafiles = [
|
144 |
+
// Red Hat, CentOS, Fedora (provided by the ca-certificates package)
|
145 |
+
'/etc/pki/tls/certs/ca-bundle.crt',
|
146 |
+
// Ubuntu, Debian (provided by the ca-certificates package)
|
147 |
+
'/etc/ssl/certs/ca-certificates.crt',
|
148 |
+
// FreeBSD (provided by the ca_root_nss package)
|
149 |
+
'/usr/local/share/certs/ca-root-nss.crt',
|
150 |
+
// SLES 12 (provided by the ca-certificates package)
|
151 |
+
'/var/lib/ca-certificates/ca-bundle.pem',
|
152 |
+
// OS X provided by homebrew (using the default path)
|
153 |
+
'/usr/local/etc/openssl/cert.pem',
|
154 |
+
// Google app engine
|
155 |
+
'/etc/ca-certificates.crt',
|
156 |
+
// Windows?
|
157 |
+
'C:\\windows\\system32\\curl-ca-bundle.crt',
|
158 |
+
'C:\\windows\\curl-ca-bundle.crt',
|
159 |
+
];
|
160 |
+
if ($cached) {
|
161 |
+
return $cached;
|
162 |
+
}
|
163 |
+
if ($ca = \ini_get('openssl.cafile')) {
|
164 |
+
return $cached = $ca;
|
165 |
+
}
|
166 |
+
if ($ca = \ini_get('curl.cainfo')) {
|
167 |
+
return $cached = $ca;
|
168 |
+
}
|
169 |
+
foreach ($cafiles as $filename) {
|
170 |
+
if (\file_exists($filename)) {
|
171 |
+
return $cached = $filename;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
throw new \RuntimeException(<<<EOT
|
175 |
+
No system CA bundle could be found in any of the the common system locations.
|
176 |
+
PHP versions earlier than 5.6 are not properly configured to use the system's
|
177 |
+
CA bundle by default. In order to verify peer certificates, you will need to
|
178 |
+
supply the path on disk to a certificate bundle to the 'verify' request
|
179 |
+
option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
|
180 |
+
need a specific certificate bundle, then Mozilla provides a commonly used CA
|
181 |
+
bundle which can be downloaded here (provided by the maintainer of cURL):
|
182 |
+
https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once
|
183 |
+
you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
|
184 |
+
ini setting to point to the path to the file, allowing you to omit the 'verify'
|
185 |
+
request option. See http://curl.haxx.se/docs/sslcerts.html for more
|
186 |
+
information.
|
187 |
+
EOT
|
188 |
+
);
|
189 |
+
}
|
190 |
+
/**
|
191 |
+
* Creates an associative array of lowercase header names to the actual
|
192 |
+
* header casing.
|
193 |
+
*
|
194 |
+
* @param array $headers
|
195 |
+
*
|
196 |
+
* @return array
|
197 |
+
*/
|
198 |
+
function normalize_header_keys(array $headers)
|
199 |
+
{
|
200 |
+
$result = [];
|
201 |
+
foreach (\array_keys($headers) as $key) {
|
202 |
+
$result[\strtolower($key)] = $key;
|
203 |
+
}
|
204 |
+
return $result;
|
205 |
+
}
|
206 |
+
/**
|
207 |
+
* Returns true if the provided host matches any of the no proxy areas.
|
208 |
+
*
|
209 |
+
* This method will strip a port from the host if it is present. Each pattern
|
210 |
+
* can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
|
211 |
+
* partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
|
212 |
+
* "baz.foo.com", but ".foo.com" != "foo.com").
|
213 |
+
*
|
214 |
+
* Areas are matched in the following cases:
|
215 |
+
* 1. "*" (without quotes) always matches any hosts.
|
216 |
+
* 2. An exact match.
|
217 |
+
* 3. The area starts with "." and the area is the last part of the host. e.g.
|
218 |
+
* '.mit.edu' will match any host that ends with '.mit.edu'.
|
219 |
+
*
|
220 |
+
* @param string $host Host to check against the patterns.
|
221 |
+
* @param array $noProxyArray An array of host patterns.
|
222 |
+
*
|
223 |
+
* @return bool
|
224 |
+
*/
|
225 |
+
function is_host_in_noproxy($host, array $noProxyArray)
|
226 |
+
{
|
227 |
+
if (\strlen($host) === 0) {
|
228 |
+
throw new \InvalidArgumentException('Empty host provided');
|
229 |
+
}
|
230 |
+
// Strip port if present.
|
231 |
+
if (\strpos($host, ':')) {
|
232 |
+
$host = \explode($host, ':', 2)[0];
|
233 |
+
}
|
234 |
+
foreach ($noProxyArray as $area) {
|
235 |
+
// Always match on wildcards.
|
236 |
+
if ($area === '*') {
|
237 |
+
return \true;
|
238 |
+
} elseif (empty($area)) {
|
239 |
+
// Don't match on empty values.
|
240 |
+
continue;
|
241 |
+
} elseif ($area === $host) {
|
242 |
+
// Exact matches.
|
243 |
+
return \true;
|
244 |
+
} else {
|
245 |
+
// Special match if the area when prefixed with ".". Remove any
|
246 |
+
// existing leading "." and add a new leading ".".
|
247 |
+
$area = '.' . \ltrim($area, '.');
|
248 |
+
if (\substr($host, -\strlen($area)) === $area) {
|
249 |
+
return \true;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
253 |
+
return \false;
|
254 |
+
}
|
255 |
+
/**
|
256 |
+
* Wrapper for json_decode that throws when an error occurs.
|
257 |
+
*
|
258 |
+
* @param string $json JSON data to parse
|
259 |
+
* @param bool $assoc When true, returned objects will be converted
|
260 |
+
* into associative arrays.
|
261 |
+
* @param int $depth User specified recursion depth.
|
262 |
+
* @param int $options Bitmask of JSON decode options.
|
263 |
+
*
|
264 |
+
* @return mixed
|
265 |
+
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
266 |
+
* @link http://www.php.net/manual/en/function.json-decode.php
|
267 |
+
*/
|
268 |
+
function json_decode($json, $assoc = \false, $depth = 512, $options = 0)
|
269 |
+
{
|
270 |
+
$data = \json_decode($json, $assoc, $depth, $options);
|
271 |
+
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
272 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
|
273 |
+
}
|
274 |
+
return $data;
|
275 |
+
}
|
276 |
+
/**
|
277 |
+
* Wrapper for JSON encoding that throws when an error occurs.
|
278 |
+
*
|
279 |
+
* @param mixed $value The value being encoded
|
280 |
+
* @param int $options JSON encode option bitmask
|
281 |
+
* @param int $depth Set the maximum depth. Must be greater than zero.
|
282 |
+
*
|
283 |
+
* @return string
|
284 |
+
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
285 |
+
* @link http://www.php.net/manual/en/function.json-encode.php
|
286 |
+
*/
|
287 |
+
function json_encode($value, $options = 0, $depth = 512)
|
288 |
+
{
|
289 |
+
$json = \json_encode($value, $options, $depth);
|
290 |
+
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
291 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Exception\InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
|
292 |
+
}
|
293 |
+
return $json;
|
294 |
+
}
|
third-party/vendor/guzzlehttp/guzzle/src/functions_include.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies;
|
4 |
+
|
5 |
+
// Don't redefine the functions if included multiple times.
|
6 |
+
if (!\function_exists('PixelCaffeine\\Dependencies\\GuzzleHttp\\uri_template')) {
|
7 |
+
require __DIR__ . '/functions.php';
|
8 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/phpstan-baseline.neon
RENAMED
File without changes
|
{vendor → third-party/vendor}/guzzlehttp/promises/psalm.xml
RENAMED
File without changes
|
third-party/vendor/guzzlehttp/promises/src/AggregateException.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exception thrown when too many errors occur in the some() or any() methods.
|
7 |
+
*/
|
8 |
+
class AggregateException extends \PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectionException
|
9 |
+
{
|
10 |
+
public function __construct($msg, array $reasons)
|
11 |
+
{
|
12 |
+
parent::__construct($reasons, \sprintf('%s; %d rejected promises', $msg, \count($reasons)));
|
13 |
+
}
|
14 |
+
}
|
third-party/vendor/guzzlehttp/promises/src/CancellationException.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exception that is set as the reason for a promise that has been cancelled.
|
7 |
+
*/
|
8 |
+
class CancellationException extends \PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectionException
|
9 |
+
{
|
10 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/Coroutine.php
RENAMED
@@ -1,11 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
use Exception;
|
6 |
use Generator;
|
7 |
use Throwable;
|
8 |
-
|
9 |
/**
|
10 |
* Creates a promise that is resolved using a generator that yields values or
|
11 |
* promises (somewhat similar to C#'s async keyword).
|
@@ -42,27 +41,24 @@ use Throwable;
|
|
42 |
*
|
43 |
* @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
44 |
*/
|
45 |
-
final class Coroutine implements PromiseInterface
|
46 |
{
|
47 |
/**
|
48 |
* @var PromiseInterface|null
|
49 |
*/
|
50 |
private $currentPromise;
|
51 |
-
|
52 |
/**
|
53 |
* @var Generator
|
54 |
*/
|
55 |
private $generator;
|
56 |
-
|
57 |
/**
|
58 |
* @var Promise
|
59 |
*/
|
60 |
private $result;
|
61 |
-
|
62 |
public function __construct(callable $generatorFn)
|
63 |
{
|
64 |
$this->generator = $generatorFn();
|
65 |
-
$this->result = new Promise(function () {
|
66 |
while (isset($this->currentPromise)) {
|
67 |
$this->currentPromise->wait();
|
68 |
}
|
@@ -71,11 +67,10 @@ final class Coroutine implements PromiseInterface
|
|
71 |
$this->nextCoroutine($this->generator->current());
|
72 |
} catch (\Exception $exception) {
|
73 |
$this->result->reject($exception);
|
74 |
-
} catch (Throwable $throwable) {
|
75 |
$this->result->reject($throwable);
|
76 |
}
|
77 |
}
|
78 |
-
|
79 |
/**
|
80 |
* Create a new coroutine.
|
81 |
*
|
@@ -85,51 +80,39 @@ final class Coroutine implements PromiseInterface
|
|
85 |
{
|
86 |
return new self($generatorFn);
|
87 |
}
|
88 |
-
|
89 |
-
|
90 |
-
callable $onFulfilled = null,
|
91 |
-
callable $onRejected = null
|
92 |
-
) {
|
93 |
return $this->result->then($onFulfilled, $onRejected);
|
94 |
}
|
95 |
-
|
96 |
public function otherwise(callable $onRejected)
|
97 |
{
|
98 |
return $this->result->otherwise($onRejected);
|
99 |
}
|
100 |
-
|
101 |
-
public function wait($unwrap = true)
|
102 |
{
|
103 |
return $this->result->wait($unwrap);
|
104 |
}
|
105 |
-
|
106 |
public function getState()
|
107 |
{
|
108 |
return $this->result->getState();
|
109 |
}
|
110 |
-
|
111 |
public function resolve($value)
|
112 |
{
|
113 |
$this->result->resolve($value);
|
114 |
}
|
115 |
-
|
116 |
public function reject($reason)
|
117 |
{
|
118 |
$this->result->reject($reason);
|
119 |
}
|
120 |
-
|
121 |
public function cancel()
|
122 |
{
|
123 |
$this->currentPromise->cancel();
|
124 |
$this->result->cancel();
|
125 |
}
|
126 |
-
|
127 |
private function nextCoroutine($yielded)
|
128 |
{
|
129 |
-
$this->currentPromise = Create::promiseFor($yielded)
|
130 |
-
->then([$this, '_handleSuccess'], [$this, '_handleFailure']);
|
131 |
}
|
132 |
-
|
133 |
/**
|
134 |
* @internal
|
135 |
*/
|
@@ -143,13 +126,12 @@ final class Coroutine implements PromiseInterface
|
|
143 |
} else {
|
144 |
$this->result->resolve($value);
|
145 |
}
|
146 |
-
} catch (Exception $exception) {
|
147 |
$this->result->reject($exception);
|
148 |
-
} catch (Throwable $throwable) {
|
149 |
$this->result->reject($throwable);
|
150 |
}
|
151 |
}
|
152 |
-
|
153 |
/**
|
154 |
* @internal
|
155 |
*/
|
@@ -157,12 +139,12 @@ final class Coroutine implements PromiseInterface
|
|
157 |
{
|
158 |
unset($this->currentPromise);
|
159 |
try {
|
160 |
-
$nextYield = $this->generator->throw(Create::exceptionFor($reason));
|
161 |
// The throw was caught, so keep iterating on the coroutine
|
162 |
$this->nextCoroutine($nextYield);
|
163 |
-
} catch (Exception $exception) {
|
164 |
$this->result->reject($exception);
|
165 |
-
} catch (Throwable $throwable) {
|
166 |
$this->result->reject($throwable);
|
167 |
}
|
168 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
use Exception;
|
6 |
use Generator;
|
7 |
use Throwable;
|
|
|
8 |
/**
|
9 |
* Creates a promise that is resolved using a generator that yields values or
|
10 |
* promises (somewhat similar to C#'s async keyword).
|
41 |
*
|
42 |
* @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
43 |
*/
|
44 |
+
final class Coroutine implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface
|
45 |
{
|
46 |
/**
|
47 |
* @var PromiseInterface|null
|
48 |
*/
|
49 |
private $currentPromise;
|
|
|
50 |
/**
|
51 |
* @var Generator
|
52 |
*/
|
53 |
private $generator;
|
|
|
54 |
/**
|
55 |
* @var Promise
|
56 |
*/
|
57 |
private $result;
|
|
|
58 |
public function __construct(callable $generatorFn)
|
59 |
{
|
60 |
$this->generator = $generatorFn();
|
61 |
+
$this->result = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise(function () {
|
62 |
while (isset($this->currentPromise)) {
|
63 |
$this->currentPromise->wait();
|
64 |
}
|
67 |
$this->nextCoroutine($this->generator->current());
|
68 |
} catch (\Exception $exception) {
|
69 |
$this->result->reject($exception);
|
70 |
+
} catch (\Throwable $throwable) {
|
71 |
$this->result->reject($throwable);
|
72 |
}
|
73 |
}
|
|
|
74 |
/**
|
75 |
* Create a new coroutine.
|
76 |
*
|
80 |
{
|
81 |
return new self($generatorFn);
|
82 |
}
|
83 |
+
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
84 |
+
{
|
|
|
|
|
|
|
85 |
return $this->result->then($onFulfilled, $onRejected);
|
86 |
}
|
|
|
87 |
public function otherwise(callable $onRejected)
|
88 |
{
|
89 |
return $this->result->otherwise($onRejected);
|
90 |
}
|
91 |
+
public function wait($unwrap = \true)
|
|
|
92 |
{
|
93 |
return $this->result->wait($unwrap);
|
94 |
}
|
|
|
95 |
public function getState()
|
96 |
{
|
97 |
return $this->result->getState();
|
98 |
}
|
|
|
99 |
public function resolve($value)
|
100 |
{
|
101 |
$this->result->resolve($value);
|
102 |
}
|
|
|
103 |
public function reject($reason)
|
104 |
{
|
105 |
$this->result->reject($reason);
|
106 |
}
|
|
|
107 |
public function cancel()
|
108 |
{
|
109 |
$this->currentPromise->cancel();
|
110 |
$this->result->cancel();
|
111 |
}
|
|
|
112 |
private function nextCoroutine($yielded)
|
113 |
{
|
114 |
+
$this->currentPromise = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::promiseFor($yielded)->then([$this, '_handleSuccess'], [$this, '_handleFailure']);
|
|
|
115 |
}
|
|
|
116 |
/**
|
117 |
* @internal
|
118 |
*/
|
126 |
} else {
|
127 |
$this->result->resolve($value);
|
128 |
}
|
129 |
+
} catch (\Exception $exception) {
|
130 |
$this->result->reject($exception);
|
131 |
+
} catch (\Throwable $throwable) {
|
132 |
$this->result->reject($throwable);
|
133 |
}
|
134 |
}
|
|
|
135 |
/**
|
136 |
* @internal
|
137 |
*/
|
139 |
{
|
140 |
unset($this->currentPromise);
|
141 |
try {
|
142 |
+
$nextYield = $this->generator->throw(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::exceptionFor($reason));
|
143 |
// The throw was caught, so keep iterating on the coroutine
|
144 |
$this->nextCoroutine($nextYield);
|
145 |
+
} catch (\Exception $exception) {
|
146 |
$this->result->reject($exception);
|
147 |
+
} catch (\Throwable $throwable) {
|
148 |
$this->result->reject($throwable);
|
149 |
}
|
150 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/Create.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
final class Create
|
6 |
{
|
@@ -13,22 +13,19 @@ final class Create
|
|
13 |
*/
|
14 |
public static function promiseFor($value)
|
15 |
{
|
16 |
-
if ($value instanceof PromiseInterface) {
|
17 |
return $value;
|
18 |
}
|
19 |
-
|
20 |
// Return a Guzzle promise that shadows the given promise.
|
21 |
-
if (is_object($value) && method_exists($value, 'then')) {
|
22 |
-
$wfn = method_exists($value, 'wait') ? [$value, 'wait'] : null;
|
23 |
-
$cfn = method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
|
24 |
-
$promise = new Promise($wfn, $cfn);
|
25 |
$value->then([$promise, 'resolve'], [$promise, 'reject']);
|
26 |
return $promise;
|
27 |
}
|
28 |
-
|
29 |
-
return new FulfilledPromise($value);
|
30 |
}
|
31 |
-
|
32 |
/**
|
33 |
* Creates a rejected promise for a reason if the reason is not a promise.
|
34 |
* If the provided reason is a promise, then it is returned as-is.
|
@@ -39,13 +36,11 @@ final class Create
|
|
39 |
*/
|
40 |
public static function rejectionFor($reason)
|
41 |
{
|
42 |
-
if ($reason instanceof PromiseInterface) {
|
43 |
return $reason;
|
44 |
}
|
45 |
-
|
46 |
-
return new RejectedPromise($reason);
|
47 |
}
|
48 |
-
|
49 |
/**
|
50 |
* Create an exception for a rejected promise value.
|
51 |
*
|
@@ -58,10 +53,8 @@ final class Create
|
|
58 |
if ($reason instanceof \Exception || $reason instanceof \Throwable) {
|
59 |
return $reason;
|
60 |
}
|
61 |
-
|
62 |
-
return new RejectionException($reason);
|
63 |
}
|
64 |
-
|
65 |
/**
|
66 |
* Returns an iterator for the given value.
|
67 |
*
|
@@ -74,11 +67,9 @@ final class Create
|
|
74 |
if ($value instanceof \Iterator) {
|
75 |
return $value;
|
76 |
}
|
77 |
-
|
78 |
-
if (is_array($value)) {
|
79 |
return new \ArrayIterator($value);
|
80 |
}
|
81 |
-
|
82 |
return new \ArrayIterator([$value]);
|
83 |
}
|
84 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
final class Create
|
6 |
{
|
13 |
*/
|
14 |
public static function promiseFor($value)
|
15 |
{
|
16 |
+
if ($value instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface) {
|
17 |
return $value;
|
18 |
}
|
|
|
19 |
// Return a Guzzle promise that shadows the given promise.
|
20 |
+
if (\is_object($value) && \method_exists($value, 'then')) {
|
21 |
+
$wfn = \method_exists($value, 'wait') ? [$value, 'wait'] : null;
|
22 |
+
$cfn = \method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
|
23 |
+
$promise = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise($wfn, $cfn);
|
24 |
$value->then([$promise, 'resolve'], [$promise, 'reject']);
|
25 |
return $promise;
|
26 |
}
|
27 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\FulfilledPromise($value);
|
|
|
28 |
}
|
|
|
29 |
/**
|
30 |
* Creates a rejected promise for a reason if the reason is not a promise.
|
31 |
* If the provided reason is a promise, then it is returned as-is.
|
36 |
*/
|
37 |
public static function rejectionFor($reason)
|
38 |
{
|
39 |
+
if ($reason instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface) {
|
40 |
return $reason;
|
41 |
}
|
42 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectedPromise($reason);
|
|
|
43 |
}
|
|
|
44 |
/**
|
45 |
* Create an exception for a rejected promise value.
|
46 |
*
|
53 |
if ($reason instanceof \Exception || $reason instanceof \Throwable) {
|
54 |
return $reason;
|
55 |
}
|
56 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectionException($reason);
|
|
|
57 |
}
|
|
|
58 |
/**
|
59 |
* Returns an iterator for the given value.
|
60 |
*
|
67 |
if ($value instanceof \Iterator) {
|
68 |
return $value;
|
69 |
}
|
70 |
+
if (\is_array($value)) {
|
|
|
71 |
return new \ArrayIterator($value);
|
72 |
}
|
|
|
73 |
return new \ArrayIterator([$value]);
|
74 |
}
|
75 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/Each.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
final class Each
|
6 |
{
|
@@ -23,17 +23,10 @@ final class Each
|
|
23 |
*
|
24 |
* @return PromiseInterface
|
25 |
*/
|
26 |
-
public static function of(
|
27 |
-
|
28 |
-
|
29 |
-
callable $onRejected = null
|
30 |
-
) {
|
31 |
-
return (new EachPromise($iterable, [
|
32 |
-
'fulfilled' => $onFulfilled,
|
33 |
-
'rejected' => $onRejected
|
34 |
-
]))->promise();
|
35 |
}
|
36 |
-
|
37 |
/**
|
38 |
* Like of, but only allows a certain number of outstanding promises at any
|
39 |
* given time.
|
@@ -49,19 +42,10 @@ final class Each
|
|
49 |
*
|
50 |
* @return PromiseInterface
|
51 |
*/
|
52 |
-
public static function ofLimit(
|
53 |
-
|
54 |
-
$concurrency
|
55 |
-
callable $onFulfilled = null,
|
56 |
-
callable $onRejected = null
|
57 |
-
) {
|
58 |
-
return (new EachPromise($iterable, [
|
59 |
-
'fulfilled' => $onFulfilled,
|
60 |
-
'rejected' => $onRejected,
|
61 |
-
'concurrency' => $concurrency
|
62 |
-
]))->promise();
|
63 |
}
|
64 |
-
|
65 |
/**
|
66 |
* Like limit, but ensures that no promise in the given $iterable argument
|
67 |
* is rejected. If any promise is rejected, then the aggregate promise is
|
@@ -73,18 +57,10 @@ final class Each
|
|
73 |
*
|
74 |
* @return PromiseInterface
|
75 |
*/
|
76 |
-
public static function ofLimitAll(
|
77 |
-
|
78 |
-
$concurrency,
|
79 |
-
|
80 |
-
|
81 |
-
return each_limit(
|
82 |
-
$iterable,
|
83 |
-
$concurrency,
|
84 |
-
$onFulfilled,
|
85 |
-
function ($reason, $idx, PromiseInterface $aggregate) {
|
86 |
-
$aggregate->reject($reason);
|
87 |
-
}
|
88 |
-
);
|
89 |
}
|
90 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
final class Each
|
6 |
{
|
23 |
*
|
24 |
* @return PromiseInterface
|
25 |
*/
|
26 |
+
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
27 |
+
{
|
28 |
+
return (new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected]))->promise();
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
|
|
30 |
/**
|
31 |
* Like of, but only allows a certain number of outstanding promises at any
|
32 |
* given time.
|
42 |
*
|
43 |
* @return PromiseInterface
|
44 |
*/
|
45 |
+
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
46 |
+
{
|
47 |
+
return (new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected, 'concurrency' => $concurrency]))->promise();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
|
|
49 |
/**
|
50 |
* Like limit, but ensures that no promise in the given $iterable argument
|
51 |
* is rejected. If any promise is rejected, then the aggregate promise is
|
57 |
*
|
58 |
* @return PromiseInterface
|
59 |
*/
|
60 |
+
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null)
|
61 |
+
{
|
62 |
+
return each_limit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $aggregate) {
|
63 |
+
$aggregate->reject($reason);
|
64 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/EachPromise.php
RENAMED
@@ -1,33 +1,26 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Represents a promise that iterates over many promises and invokes
|
7 |
* side-effect functions in the process.
|
8 |
*/
|
9 |
-
class EachPromise implements PromisorInterface
|
10 |
{
|
11 |
private $pending = [];
|
12 |
-
|
13 |
/** @var \Iterator|null */
|
14 |
private $iterable;
|
15 |
-
|
16 |
/** @var callable|int|null */
|
17 |
private $concurrency;
|
18 |
-
|
19 |
/** @var callable|null */
|
20 |
private $onFulfilled;
|
21 |
-
|
22 |
/** @var callable|null */
|
23 |
private $onRejected;
|
24 |
-
|
25 |
/** @var Promise|null */
|
26 |
private $aggregate;
|
27 |
-
|
28 |
/** @var bool|null */
|
29 |
private $mutex;
|
30 |
-
|
31 |
/**
|
32 |
* Configuration hash can include the following key value pairs:
|
33 |
*
|
@@ -51,28 +44,23 @@ class EachPromise implements PromisorInterface
|
|
51 |
*/
|
52 |
public function __construct($iterable, array $config = [])
|
53 |
{
|
54 |
-
$this->iterable = Create::iterFor($iterable);
|
55 |
-
|
56 |
if (isset($config['concurrency'])) {
|
57 |
$this->concurrency = $config['concurrency'];
|
58 |
}
|
59 |
-
|
60 |
if (isset($config['fulfilled'])) {
|
61 |
$this->onFulfilled = $config['fulfilled'];
|
62 |
}
|
63 |
-
|
64 |
if (isset($config['rejected'])) {
|
65 |
$this->onRejected = $config['rejected'];
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
/** @psalm-suppress InvalidNullableReturnType */
|
70 |
public function promise()
|
71 |
{
|
72 |
if ($this->aggregate) {
|
73 |
return $this->aggregate;
|
74 |
}
|
75 |
-
|
76 |
try {
|
77 |
$this->createPromise();
|
78 |
/** @psalm-assert Promise $this->aggregate */
|
@@ -93,52 +81,45 @@ class EachPromise implements PromisorInterface
|
|
93 |
*/
|
94 |
$this->aggregate->reject($e);
|
95 |
}
|
96 |
-
|
97 |
/**
|
98 |
* @psalm-suppress NullableReturnStatement
|
99 |
* @phpstan-ignore-next-line
|
100 |
*/
|
101 |
return $this->aggregate;
|
102 |
}
|
103 |
-
|
104 |
private function createPromise()
|
105 |
{
|
106 |
-
$this->mutex = false;
|
107 |
-
$this->aggregate = new Promise(function () {
|
108 |
-
reset($this->pending);
|
109 |
// Consume a potentially fluctuating list of promises while
|
110 |
// ensuring that indexes are maintained (precluding array_shift).
|
111 |
-
while ($promise = current($this->pending)) {
|
112 |
-
next($this->pending);
|
113 |
$promise->wait();
|
114 |
-
if (Is::settled($this->aggregate)) {
|
115 |
return;
|
116 |
}
|
117 |
}
|
118 |
});
|
119 |
-
|
120 |
// Clear the references when the promise is resolved.
|
121 |
$clearFn = function () {
|
122 |
$this->iterable = $this->concurrency = $this->pending = null;
|
123 |
$this->onFulfilled = $this->onRejected = null;
|
124 |
};
|
125 |
-
|
126 |
$this->aggregate->then($clearFn, $clearFn);
|
127 |
}
|
128 |
-
|
129 |
private function refillPending()
|
130 |
{
|
131 |
if (!$this->concurrency) {
|
132 |
// Add all pending promises.
|
133 |
-
while ($this->addPending() && $this->advanceIterator())
|
|
|
134 |
return;
|
135 |
}
|
136 |
-
|
137 |
// Add only up to N pending promises.
|
138 |
-
$concurrency = is_callable($this->concurrency)
|
139 |
-
|
140 |
-
: $this->concurrency;
|
141 |
-
$concurrency = max($concurrency - count($this->pending), 0);
|
142 |
// Concurrency may be set to 0 to disallow new promises.
|
143 |
if (!$concurrency) {
|
144 |
return;
|
@@ -149,88 +130,63 @@ class EachPromise implements PromisorInterface
|
|
149 |
// not advance the iterator after adding the first promise. This
|
150 |
// helps work around issues with generators that might not have the
|
151 |
// next value to yield until promise callbacks are called.
|
152 |
-
while (--$concurrency
|
153 |
-
|
154 |
-
&& $this->addPending());
|
155 |
}
|
156 |
-
|
157 |
private function addPending()
|
158 |
{
|
159 |
if (!$this->iterable || !$this->iterable->valid()) {
|
160 |
-
return false;
|
161 |
}
|
162 |
-
|
163 |
-
$promise = Create::promiseFor($this->iterable->current());
|
164 |
$key = $this->iterable->key();
|
165 |
-
|
166 |
// Iterable keys may not be unique, so we add the promises at the end
|
167 |
// of the pending array and retrieve the array index being used
|
168 |
$this->pending[] = null;
|
169 |
-
end($this->pending);
|
170 |
-
$idx = key($this->pending);
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
if ($this->onFulfilled) {
|
175 |
-
call_user_func(
|
176 |
-
$this->onFulfilled,
|
177 |
-
$value,
|
178 |
-
$key,
|
179 |
-
$this->aggregate
|
180 |
-
);
|
181 |
-
}
|
182 |
-
$this->step($idx);
|
183 |
-
},
|
184 |
-
function ($reason) use ($idx, $key) {
|
185 |
-
if ($this->onRejected) {
|
186 |
-
call_user_func(
|
187 |
-
$this->onRejected,
|
188 |
-
$reason,
|
189 |
-
$key,
|
190 |
-
$this->aggregate
|
191 |
-
);
|
192 |
-
}
|
193 |
-
$this->step($idx);
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
-
|
200 |
private function advanceIterator()
|
201 |
{
|
202 |
// Place a lock on the iterator so that we ensure to not recurse,
|
203 |
// preventing fatal generator errors.
|
204 |
if ($this->mutex) {
|
205 |
-
return false;
|
206 |
}
|
207 |
-
|
208 |
-
$this->mutex = true;
|
209 |
-
|
210 |
try {
|
211 |
$this->iterable->next();
|
212 |
-
$this->mutex = false;
|
213 |
-
return true;
|
214 |
} catch (\Throwable $e) {
|
215 |
$this->aggregate->reject($e);
|
216 |
-
$this->mutex = false;
|
217 |
-
return false;
|
218 |
} catch (\Exception $e) {
|
219 |
$this->aggregate->reject($e);
|
220 |
-
$this->mutex = false;
|
221 |
-
return false;
|
222 |
}
|
223 |
}
|
224 |
-
|
225 |
private function step($idx)
|
226 |
{
|
227 |
// If the promise was already resolved, then ignore this step.
|
228 |
-
if (Is::settled($this->aggregate)) {
|
229 |
return;
|
230 |
}
|
231 |
-
|
232 |
unset($this->pending[$idx]);
|
233 |
-
|
234 |
// Only refill pending promises if we are not locked, preventing the
|
235 |
// EachPromise to recursively invoke the provided iterator, which
|
236 |
// cause a fatal error: "Cannot resume an already running generator"
|
@@ -239,15 +195,13 @@ class EachPromise implements PromisorInterface
|
|
239 |
$this->refillPending();
|
240 |
}
|
241 |
}
|
242 |
-
|
243 |
private function checkIfFinished()
|
244 |
{
|
245 |
if (!$this->pending && !$this->iterable->valid()) {
|
246 |
// Resolve the promise if there's nothing left to do.
|
247 |
$this->aggregate->resolve(null);
|
248 |
-
return true;
|
249 |
}
|
250 |
-
|
251 |
-
return false;
|
252 |
}
|
253 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Represents a promise that iterates over many promises and invokes
|
7 |
* side-effect functions in the process.
|
8 |
*/
|
9 |
+
class EachPromise implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromisorInterface
|
10 |
{
|
11 |
private $pending = [];
|
|
|
12 |
/** @var \Iterator|null */
|
13 |
private $iterable;
|
|
|
14 |
/** @var callable|int|null */
|
15 |
private $concurrency;
|
|
|
16 |
/** @var callable|null */
|
17 |
private $onFulfilled;
|
|
|
18 |
/** @var callable|null */
|
19 |
private $onRejected;
|
|
|
20 |
/** @var Promise|null */
|
21 |
private $aggregate;
|
|
|
22 |
/** @var bool|null */
|
23 |
private $mutex;
|
|
|
24 |
/**
|
25 |
* Configuration hash can include the following key value pairs:
|
26 |
*
|
44 |
*/
|
45 |
public function __construct($iterable, array $config = [])
|
46 |
{
|
47 |
+
$this->iterable = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::iterFor($iterable);
|
|
|
48 |
if (isset($config['concurrency'])) {
|
49 |
$this->concurrency = $config['concurrency'];
|
50 |
}
|
|
|
51 |
if (isset($config['fulfilled'])) {
|
52 |
$this->onFulfilled = $config['fulfilled'];
|
53 |
}
|
|
|
54 |
if (isset($config['rejected'])) {
|
55 |
$this->onRejected = $config['rejected'];
|
56 |
}
|
57 |
}
|
|
|
58 |
/** @psalm-suppress InvalidNullableReturnType */
|
59 |
public function promise()
|
60 |
{
|
61 |
if ($this->aggregate) {
|
62 |
return $this->aggregate;
|
63 |
}
|
|
|
64 |
try {
|
65 |
$this->createPromise();
|
66 |
/** @psalm-assert Promise $this->aggregate */
|
81 |
*/
|
82 |
$this->aggregate->reject($e);
|
83 |
}
|
|
|
84 |
/**
|
85 |
* @psalm-suppress NullableReturnStatement
|
86 |
* @phpstan-ignore-next-line
|
87 |
*/
|
88 |
return $this->aggregate;
|
89 |
}
|
|
|
90 |
private function createPromise()
|
91 |
{
|
92 |
+
$this->mutex = \false;
|
93 |
+
$this->aggregate = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise(function () {
|
94 |
+
\reset($this->pending);
|
95 |
// Consume a potentially fluctuating list of promises while
|
96 |
// ensuring that indexes are maintained (precluding array_shift).
|
97 |
+
while ($promise = \current($this->pending)) {
|
98 |
+
\next($this->pending);
|
99 |
$promise->wait();
|
100 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::settled($this->aggregate)) {
|
101 |
return;
|
102 |
}
|
103 |
}
|
104 |
});
|
|
|
105 |
// Clear the references when the promise is resolved.
|
106 |
$clearFn = function () {
|
107 |
$this->iterable = $this->concurrency = $this->pending = null;
|
108 |
$this->onFulfilled = $this->onRejected = null;
|
109 |
};
|
|
|
110 |
$this->aggregate->then($clearFn, $clearFn);
|
111 |
}
|
|
|
112 |
private function refillPending()
|
113 |
{
|
114 |
if (!$this->concurrency) {
|
115 |
// Add all pending promises.
|
116 |
+
while ($this->addPending() && $this->advanceIterator()) {
|
117 |
+
}
|
118 |
return;
|
119 |
}
|
|
|
120 |
// Add only up to N pending promises.
|
121 |
+
$concurrency = \is_callable($this->concurrency) ? \call_user_func($this->concurrency, \count($this->pending)) : $this->concurrency;
|
122 |
+
$concurrency = \max($concurrency - \count($this->pending), 0);
|
|
|
|
|
123 |
// Concurrency may be set to 0 to disallow new promises.
|
124 |
if (!$concurrency) {
|
125 |
return;
|
130 |
// not advance the iterator after adding the first promise. This
|
131 |
// helps work around issues with generators that might not have the
|
132 |
// next value to yield until promise callbacks are called.
|
133 |
+
while (--$concurrency && $this->advanceIterator() && $this->addPending()) {
|
134 |
+
}
|
|
|
135 |
}
|
|
|
136 |
private function addPending()
|
137 |
{
|
138 |
if (!$this->iterable || !$this->iterable->valid()) {
|
139 |
+
return \false;
|
140 |
}
|
141 |
+
$promise = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::promiseFor($this->iterable->current());
|
|
|
142 |
$key = $this->iterable->key();
|
|
|
143 |
// Iterable keys may not be unique, so we add the promises at the end
|
144 |
// of the pending array and retrieve the array index being used
|
145 |
$this->pending[] = null;
|
146 |
+
\end($this->pending);
|
147 |
+
$idx = \key($this->pending);
|
148 |
+
$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) {
|
149 |
+
if ($this->onFulfilled) {
|
150 |
+
\call_user_func($this->onFulfilled, $value, $key, $this->aggregate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
+
$this->step($idx);
|
153 |
+
}, function ($reason) use($idx, $key) {
|
154 |
+
if ($this->onRejected) {
|
155 |
+
\call_user_func($this->onRejected, $reason, $key, $this->aggregate);
|
156 |
+
}
|
157 |
+
$this->step($idx);
|
158 |
+
});
|
159 |
+
return \true;
|
160 |
}
|
|
|
161 |
private function advanceIterator()
|
162 |
{
|
163 |
// Place a lock on the iterator so that we ensure to not recurse,
|
164 |
// preventing fatal generator errors.
|
165 |
if ($this->mutex) {
|
166 |
+
return \false;
|
167 |
}
|
168 |
+
$this->mutex = \true;
|
|
|
|
|
169 |
try {
|
170 |
$this->iterable->next();
|
171 |
+
$this->mutex = \false;
|
172 |
+
return \true;
|
173 |
} catch (\Throwable $e) {
|
174 |
$this->aggregate->reject($e);
|
175 |
+
$this->mutex = \false;
|
176 |
+
return \false;
|
177 |
} catch (\Exception $e) {
|
178 |
$this->aggregate->reject($e);
|
179 |
+
$this->mutex = \false;
|
180 |
+
return \false;
|
181 |
}
|
182 |
}
|
|
|
183 |
private function step($idx)
|
184 |
{
|
185 |
// If the promise was already resolved, then ignore this step.
|
186 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::settled($this->aggregate)) {
|
187 |
return;
|
188 |
}
|
|
|
189 |
unset($this->pending[$idx]);
|
|
|
190 |
// Only refill pending promises if we are not locked, preventing the
|
191 |
// EachPromise to recursively invoke the provided iterator, which
|
192 |
// cause a fatal error: "Cannot resume an already running generator"
|
195 |
$this->refillPending();
|
196 |
}
|
197 |
}
|
|
|
198 |
private function checkIfFinished()
|
199 |
{
|
200 |
if (!$this->pending && !$this->iterable->valid()) {
|
201 |
// Resolve the promise if there's nothing left to do.
|
202 |
$this->aggregate->resolve(null);
|
203 |
+
return \true;
|
204 |
}
|
205 |
+
return \false;
|
|
|
206 |
}
|
207 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/FulfilledPromise.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise that has been fulfilled.
|
@@ -8,35 +8,27 @@ namespace GuzzleHttp\Promise;
|
|
8 |
* Thenning off of this promise will invoke the onFulfilled callback
|
9 |
* immediately and ignore other callbacks.
|
10 |
*/
|
11 |
-
class FulfilledPromise implements PromiseInterface
|
12 |
{
|
13 |
private $value;
|
14 |
-
|
15 |
public function __construct($value)
|
16 |
{
|
17 |
-
if (is_object($value) && method_exists($value, 'then')) {
|
18 |
-
throw new \InvalidArgumentException(
|
19 |
-
'You cannot create a FulfilledPromise with a promise.'
|
20 |
-
);
|
21 |
}
|
22 |
-
|
23 |
$this->value = $value;
|
24 |
}
|
25 |
-
|
26 |
-
|
27 |
-
callable $onFulfilled = null,
|
28 |
-
callable $onRejected = null
|
29 |
-
) {
|
30 |
// Return itself if there is no onFulfilled function.
|
31 |
if (!$onFulfilled) {
|
32 |
return $this;
|
33 |
}
|
34 |
-
|
35 |
-
$
|
36 |
-
$p = new Promise([$queue, 'run']);
|
37 |
$value = $this->value;
|
38 |
-
$queue->add(static function () use
|
39 |
-
if (Is::pending($p)) {
|
40 |
try {
|
41 |
$p->resolve($onFulfilled($value));
|
42 |
} catch (\Throwable $e) {
|
@@ -46,37 +38,30 @@ class FulfilledPromise implements PromiseInterface
|
|
46 |
}
|
47 |
}
|
48 |
});
|
49 |
-
|
50 |
return $p;
|
51 |
}
|
52 |
-
|
53 |
public function otherwise(callable $onRejected)
|
54 |
{
|
55 |
return $this->then(null, $onRejected);
|
56 |
}
|
57 |
-
|
58 |
-
public function wait($unwrap = true, $defaultDelivery = null)
|
59 |
{
|
60 |
return $unwrap ? $this->value : null;
|
61 |
}
|
62 |
-
|
63 |
public function getState()
|
64 |
{
|
65 |
return self::FULFILLED;
|
66 |
}
|
67 |
-
|
68 |
public function resolve($value)
|
69 |
{
|
70 |
if ($value !== $this->value) {
|
71 |
throw new \LogicException("Cannot resolve a fulfilled promise");
|
72 |
}
|
73 |
}
|
74 |
-
|
75 |
public function reject($reason)
|
76 |
{
|
77 |
throw new \LogicException("Cannot reject a fulfilled promise");
|
78 |
}
|
79 |
-
|
80 |
public function cancel()
|
81 |
{
|
82 |
// pass
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise that has been fulfilled.
|
8 |
* Thenning off of this promise will invoke the onFulfilled callback
|
9 |
* immediately and ignore other callbacks.
|
10 |
*/
|
11 |
+
class FulfilledPromise implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface
|
12 |
{
|
13 |
private $value;
|
|
|
14 |
public function __construct($value)
|
15 |
{
|
16 |
+
if (\is_object($value) && \method_exists($value, 'then')) {
|
17 |
+
throw new \InvalidArgumentException('You cannot create a FulfilledPromise with a promise.');
|
|
|
|
|
18 |
}
|
|
|
19 |
$this->value = $value;
|
20 |
}
|
21 |
+
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
22 |
+
{
|
|
|
|
|
|
|
23 |
// Return itself if there is no onFulfilled function.
|
24 |
if (!$onFulfilled) {
|
25 |
return $this;
|
26 |
}
|
27 |
+
$queue = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::queue();
|
28 |
+
$p = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
|
|
29 |
$value = $this->value;
|
30 |
+
$queue->add(static function () use($p, $value, $onFulfilled) {
|
31 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::pending($p)) {
|
32 |
try {
|
33 |
$p->resolve($onFulfilled($value));
|
34 |
} catch (\Throwable $e) {
|
38 |
}
|
39 |
}
|
40 |
});
|
|
|
41 |
return $p;
|
42 |
}
|
|
|
43 |
public function otherwise(callable $onRejected)
|
44 |
{
|
45 |
return $this->then(null, $onRejected);
|
46 |
}
|
47 |
+
public function wait($unwrap = \true, $defaultDelivery = null)
|
|
|
48 |
{
|
49 |
return $unwrap ? $this->value : null;
|
50 |
}
|
|
|
51 |
public function getState()
|
52 |
{
|
53 |
return self::FULFILLED;
|
54 |
}
|
|
|
55 |
public function resolve($value)
|
56 |
{
|
57 |
if ($value !== $this->value) {
|
58 |
throw new \LogicException("Cannot resolve a fulfilled promise");
|
59 |
}
|
60 |
}
|
|
|
61 |
public function reject($reason)
|
62 |
{
|
63 |
throw new \LogicException("Cannot reject a fulfilled promise");
|
64 |
}
|
|
|
65 |
public function cancel()
|
66 |
{
|
67 |
// pass
|
third-party/vendor/guzzlehttp/promises/src/Is.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
+
|
5 |
+
final class Is
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Returns true if a promise is pending.
|
9 |
+
*
|
10 |
+
* @return bool
|
11 |
+
*/
|
12 |
+
public static function pending(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
13 |
+
{
|
14 |
+
return $promise->getState() === \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
15 |
+
}
|
16 |
+
/**
|
17 |
+
* Returns true if a promise is fulfilled or rejected.
|
18 |
+
*
|
19 |
+
* @return bool
|
20 |
+
*/
|
21 |
+
public static function settled(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
22 |
+
{
|
23 |
+
return $promise->getState() !== \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
24 |
+
}
|
25 |
+
/**
|
26 |
+
* Returns true if a promise is fulfilled.
|
27 |
+
*
|
28 |
+
* @return bool
|
29 |
+
*/
|
30 |
+
public static function fulfilled(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
31 |
+
{
|
32 |
+
return $promise->getState() === \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::FULFILLED;
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Returns true if a promise is rejected.
|
36 |
+
*
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public static function rejected(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
40 |
+
{
|
41 |
+
return $promise->getState() === \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::REJECTED;
|
42 |
+
}
|
43 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/Promise.php
RENAMED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Promises/A+ implementation that avoids recursion when possible.
|
7 |
*
|
8 |
* @link https://promisesaplus.com/
|
9 |
*/
|
10 |
-
class Promise implements PromiseInterface
|
11 |
{
|
12 |
private $state = self::PENDING;
|
13 |
private $result;
|
@@ -15,53 +15,42 @@ class Promise implements PromiseInterface
|
|
15 |
private $waitFn;
|
16 |
private $waitList;
|
17 |
private $handlers = [];
|
18 |
-
|
19 |
/**
|
20 |
* @param callable $waitFn Fn that when invoked resolves the promise.
|
21 |
* @param callable $cancelFn Fn that when invoked cancels the promise.
|
22 |
*/
|
23 |
-
public function __construct(
|
24 |
-
|
25 |
-
callable $cancelFn = null
|
26 |
-
) {
|
27 |
$this->waitFn = $waitFn;
|
28 |
$this->cancelFn = $cancelFn;
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
callable $onFulfilled = null,
|
33 |
-
callable $onRejected = null
|
34 |
-
) {
|
35 |
if ($this->state === self::PENDING) {
|
36 |
-
$p = new Promise(null, [$this, 'cancel']);
|
37 |
$this->handlers[] = [$p, $onFulfilled, $onRejected];
|
38 |
$p->waitList = $this->waitList;
|
39 |
$p->waitList[] = $this;
|
40 |
return $p;
|
41 |
}
|
42 |
-
|
43 |
// Return a fulfilled promise and immediately invoke any callbacks.
|
44 |
if ($this->state === self::FULFILLED) {
|
45 |
-
$promise = Create::promiseFor($this->result);
|
46 |
return $onFulfilled ? $promise->then($onFulfilled) : $promise;
|
47 |
}
|
48 |
-
|
49 |
// It's either cancelled or rejected, so return a rejected promise
|
50 |
// and immediately invoke any callbacks.
|
51 |
-
$rejection = Create::rejectionFor($this->result);
|
52 |
return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
|
53 |
}
|
54 |
-
|
55 |
public function otherwise(callable $onRejected)
|
56 |
{
|
57 |
return $this->then(null, $onRejected);
|
58 |
}
|
59 |
-
|
60 |
-
public function wait($unwrap = true)
|
61 |
{
|
62 |
$this->waitIfPending();
|
63 |
-
|
64 |
-
if ($this->result instanceof PromiseInterface) {
|
65 |
return $this->result->wait($unwrap);
|
66 |
}
|
67 |
if ($unwrap) {
|
@@ -69,23 +58,19 @@ class Promise implements PromiseInterface
|
|
69 |
return $this->result;
|
70 |
}
|
71 |
// It's rejected so "unwrap" and throw an exception.
|
72 |
-
throw Create::exceptionFor($this->result);
|
73 |
}
|
74 |
}
|
75 |
-
|
76 |
public function getState()
|
77 |
{
|
78 |
return $this->state;
|
79 |
}
|
80 |
-
|
81 |
public function cancel()
|
82 |
{
|
83 |
if ($this->state !== self::PENDING) {
|
84 |
return;
|
85 |
}
|
86 |
-
|
87 |
$this->waitFn = $this->waitList = null;
|
88 |
-
|
89 |
if ($this->cancelFn) {
|
90 |
$fn = $this->cancelFn;
|
91 |
$this->cancelFn = null;
|
@@ -97,24 +82,20 @@ class Promise implements PromiseInterface
|
|
97 |
$this->reject($e);
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
// Reject the promise only if it wasn't rejected in a then callback.
|
102 |
/** @psalm-suppress RedundantCondition */
|
103 |
if ($this->state === self::PENDING) {
|
104 |
-
$this->reject(new CancellationException('Promise has been cancelled'));
|
105 |
}
|
106 |
}
|
107 |
-
|
108 |
public function resolve($value)
|
109 |
{
|
110 |
$this->settle(self::FULFILLED, $value);
|
111 |
}
|
112 |
-
|
113 |
public function reject($reason)
|
114 |
{
|
115 |
$this->settle(self::REJECTED, $reason);
|
116 |
}
|
117 |
-
|
118 |
private function settle($state, $value)
|
119 |
{
|
120 |
if ($this->state !== self::PENDING) {
|
@@ -122,15 +103,11 @@ class Promise implements PromiseInterface
|
|
122 |
if ($state === $this->state && $value === $this->result) {
|
123 |
return;
|
124 |
}
|
125 |
-
throw $this->state === $state
|
126 |
-
? new \LogicException("The promise is already {$state}.")
|
127 |
-
: new \LogicException("Cannot change a {$this->state} promise to {$state}");
|
128 |
}
|
129 |
-
|
130 |
if ($value === $this) {
|
131 |
throw new \LogicException('Cannot fulfill or reject a promise with itself');
|
132 |
}
|
133 |
-
|
134 |
// Clear out the state of the promise but stash the handlers.
|
135 |
$this->state = $state;
|
136 |
$this->result = $value;
|
@@ -138,41 +115,35 @@ class Promise implements PromiseInterface
|
|
138 |
$this->handlers = null;
|
139 |
$this->waitList = $this->waitFn = null;
|
140 |
$this->cancelFn = null;
|
141 |
-
|
142 |
if (!$handlers) {
|
143 |
return;
|
144 |
}
|
145 |
-
|
146 |
// If the value was not a settled promise or a thenable, then resolve
|
147 |
// it in the task queue using the correct ID.
|
148 |
-
if (
|
149 |
$id = $state === self::FULFILLED ? 1 : 2;
|
150 |
// It's a success, so resolve the handlers in the queue.
|
151 |
-
Utils::queue()->add(static function () use
|
152 |
foreach ($handlers as $handler) {
|
153 |
self::callHandler($id, $value, $handler);
|
154 |
}
|
155 |
});
|
156 |
-
} elseif ($value instanceof Promise && Is::pending($value)) {
|
157 |
// We can just merge our handlers onto the next promise.
|
158 |
-
$value->handlers = array_merge($value->handlers, $handlers);
|
159 |
} else {
|
160 |
// Resolve the handlers when the forwarded promise is resolved.
|
161 |
-
$value->then(
|
162 |
-
|
163 |
-
|
164 |
-
self::callHandler(1, $value, $handler);
|
165 |
-
}
|
166 |
-
},
|
167 |
-
static function ($reason) use ($handlers) {
|
168 |
-
foreach ($handlers as $handler) {
|
169 |
-
self::callHandler(2, $reason, $handler);
|
170 |
-
}
|
171 |
}
|
172 |
-
)
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
}
|
175 |
-
|
176 |
/**
|
177 |
* Call a stack of handlers using a specific callback index and value.
|
178 |
*
|
@@ -184,13 +155,11 @@ class Promise implements PromiseInterface
|
|
184 |
{
|
185 |
/** @var PromiseInterface $promise */
|
186 |
$promise = $handler[0];
|
187 |
-
|
188 |
// The promise may have been cancelled or resolved before placing
|
189 |
// this thunk in the queue.
|
190 |
-
if (Is::settled($promise)) {
|
191 |
return;
|
192 |
}
|
193 |
-
|
194 |
try {
|
195 |
if (isset($handler[$index])) {
|
196 |
/*
|
@@ -215,7 +184,6 @@ class Promise implements PromiseInterface
|
|
215 |
$promise->reject($reason);
|
216 |
}
|
217 |
}
|
218 |
-
|
219 |
private function waitIfPending()
|
220 |
{
|
221 |
if ($this->state !== self::PENDING) {
|
@@ -226,26 +194,20 @@ class Promise implements PromiseInterface
|
|
226 |
$this->invokeWaitList();
|
227 |
} else {
|
228 |
// If there's no wait function, then reject the promise.
|
229 |
-
$this->reject('Cannot wait on a promise that has '
|
230 |
-
. 'no internal wait function. You must provide a wait '
|
231 |
-
. 'function when constructing the promise to be able to '
|
232 |
-
. 'wait on a promise.');
|
233 |
}
|
234 |
-
|
235 |
-
Utils::queue()->run();
|
236 |
-
|
237 |
/** @psalm-suppress RedundantCondition */
|
238 |
if ($this->state === self::PENDING) {
|
239 |
$this->reject('Invoking the wait callback did not resolve the promise');
|
240 |
}
|
241 |
}
|
242 |
-
|
243 |
private function invokeWaitFn()
|
244 |
{
|
245 |
try {
|
246 |
$wfn = $this->waitFn;
|
247 |
$this->waitFn = null;
|
248 |
-
$wfn(true);
|
249 |
} catch (\Exception $reason) {
|
250 |
if ($this->state === self::PENDING) {
|
251 |
// The promise has not been resolved yet, so reject the promise
|
@@ -258,20 +220,17 @@ class Promise implements PromiseInterface
|
|
258 |
}
|
259 |
}
|
260 |
}
|
261 |
-
|
262 |
private function invokeWaitList()
|
263 |
{
|
264 |
$waitList = $this->waitList;
|
265 |
$this->waitList = null;
|
266 |
-
|
267 |
foreach ($waitList as $result) {
|
268 |
do {
|
269 |
$result->waitIfPending();
|
270 |
$result = $result->result;
|
271 |
-
} while ($result instanceof Promise);
|
272 |
-
|
273 |
-
|
274 |
-
$result->wait(false);
|
275 |
}
|
276 |
}
|
277 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Promises/A+ implementation that avoids recursion when possible.
|
7 |
*
|
8 |
* @link https://promisesaplus.com/
|
9 |
*/
|
10 |
+
class Promise implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface
|
11 |
{
|
12 |
private $state = self::PENDING;
|
13 |
private $result;
|
15 |
private $waitFn;
|
16 |
private $waitList;
|
17 |
private $handlers = [];
|
|
|
18 |
/**
|
19 |
* @param callable $waitFn Fn that when invoked resolves the promise.
|
20 |
* @param callable $cancelFn Fn that when invoked cancels the promise.
|
21 |
*/
|
22 |
+
public function __construct(callable $waitFn = null, callable $cancelFn = null)
|
23 |
+
{
|
|
|
|
|
24 |
$this->waitFn = $waitFn;
|
25 |
$this->cancelFn = $cancelFn;
|
26 |
}
|
27 |
+
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
28 |
+
{
|
|
|
|
|
|
|
29 |
if ($this->state === self::PENDING) {
|
30 |
+
$p = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise(null, [$this, 'cancel']);
|
31 |
$this->handlers[] = [$p, $onFulfilled, $onRejected];
|
32 |
$p->waitList = $this->waitList;
|
33 |
$p->waitList[] = $this;
|
34 |
return $p;
|
35 |
}
|
|
|
36 |
// Return a fulfilled promise and immediately invoke any callbacks.
|
37 |
if ($this->state === self::FULFILLED) {
|
38 |
+
$promise = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::promiseFor($this->result);
|
39 |
return $onFulfilled ? $promise->then($onFulfilled) : $promise;
|
40 |
}
|
|
|
41 |
// It's either cancelled or rejected, so return a rejected promise
|
42 |
// and immediately invoke any callbacks.
|
43 |
+
$rejection = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::rejectionFor($this->result);
|
44 |
return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
|
45 |
}
|
|
|
46 |
public function otherwise(callable $onRejected)
|
47 |
{
|
48 |
return $this->then(null, $onRejected);
|
49 |
}
|
50 |
+
public function wait($unwrap = \true)
|
|
|
51 |
{
|
52 |
$this->waitIfPending();
|
53 |
+
if ($this->result instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface) {
|
|
|
54 |
return $this->result->wait($unwrap);
|
55 |
}
|
56 |
if ($unwrap) {
|
58 |
return $this->result;
|
59 |
}
|
60 |
// It's rejected so "unwrap" and throw an exception.
|
61 |
+
throw \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::exceptionFor($this->result);
|
62 |
}
|
63 |
}
|
|
|
64 |
public function getState()
|
65 |
{
|
66 |
return $this->state;
|
67 |
}
|
|
|
68 |
public function cancel()
|
69 |
{
|
70 |
if ($this->state !== self::PENDING) {
|
71 |
return;
|
72 |
}
|
|
|
73 |
$this->waitFn = $this->waitList = null;
|
|
|
74 |
if ($this->cancelFn) {
|
75 |
$fn = $this->cancelFn;
|
76 |
$this->cancelFn = null;
|
82 |
$this->reject($e);
|
83 |
}
|
84 |
}
|
|
|
85 |
// Reject the promise only if it wasn't rejected in a then callback.
|
86 |
/** @psalm-suppress RedundantCondition */
|
87 |
if ($this->state === self::PENDING) {
|
88 |
+
$this->reject(new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\CancellationException('Promise has been cancelled'));
|
89 |
}
|
90 |
}
|
|
|
91 |
public function resolve($value)
|
92 |
{
|
93 |
$this->settle(self::FULFILLED, $value);
|
94 |
}
|
|
|
95 |
public function reject($reason)
|
96 |
{
|
97 |
$this->settle(self::REJECTED, $reason);
|
98 |
}
|
|
|
99 |
private function settle($state, $value)
|
100 |
{
|
101 |
if ($this->state !== self::PENDING) {
|
103 |
if ($state === $this->state && $value === $this->result) {
|
104 |
return;
|
105 |
}
|
106 |
+
throw $this->state === $state ? new \LogicException("The promise is already {$state}.") : new \LogicException("Cannot change a {$this->state} promise to {$state}");
|
|
|
|
|
107 |
}
|
|
|
108 |
if ($value === $this) {
|
109 |
throw new \LogicException('Cannot fulfill or reject a promise with itself');
|
110 |
}
|
|
|
111 |
// Clear out the state of the promise but stash the handlers.
|
112 |
$this->state = $state;
|
113 |
$this->result = $value;
|
115 |
$this->handlers = null;
|
116 |
$this->waitList = $this->waitFn = null;
|
117 |
$this->cancelFn = null;
|
|
|
118 |
if (!$handlers) {
|
119 |
return;
|
120 |
}
|
|
|
121 |
// If the value was not a settled promise or a thenable, then resolve
|
122 |
// it in the task queue using the correct ID.
|
123 |
+
if (!\is_object($value) || !\method_exists($value, 'then')) {
|
124 |
$id = $state === self::FULFILLED ? 1 : 2;
|
125 |
// It's a success, so resolve the handlers in the queue.
|
126 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::queue()->add(static function () use($id, $value, $handlers) {
|
127 |
foreach ($handlers as $handler) {
|
128 |
self::callHandler($id, $value, $handler);
|
129 |
}
|
130 |
});
|
131 |
+
} elseif ($value instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise && \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::pending($value)) {
|
132 |
// We can just merge our handlers onto the next promise.
|
133 |
+
$value->handlers = \array_merge($value->handlers, $handlers);
|
134 |
} else {
|
135 |
// Resolve the handlers when the forwarded promise is resolved.
|
136 |
+
$value->then(static function ($value) use($handlers) {
|
137 |
+
foreach ($handlers as $handler) {
|
138 |
+
self::callHandler(1, $value, $handler);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
+
}, static function ($reason) use($handlers) {
|
141 |
+
foreach ($handlers as $handler) {
|
142 |
+
self::callHandler(2, $reason, $handler);
|
143 |
+
}
|
144 |
+
});
|
145 |
}
|
146 |
}
|
|
|
147 |
/**
|
148 |
* Call a stack of handlers using a specific callback index and value.
|
149 |
*
|
155 |
{
|
156 |
/** @var PromiseInterface $promise */
|
157 |
$promise = $handler[0];
|
|
|
158 |
// The promise may have been cancelled or resolved before placing
|
159 |
// this thunk in the queue.
|
160 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::settled($promise)) {
|
161 |
return;
|
162 |
}
|
|
|
163 |
try {
|
164 |
if (isset($handler[$index])) {
|
165 |
/*
|
184 |
$promise->reject($reason);
|
185 |
}
|
186 |
}
|
|
|
187 |
private function waitIfPending()
|
188 |
{
|
189 |
if ($this->state !== self::PENDING) {
|
194 |
$this->invokeWaitList();
|
195 |
} else {
|
196 |
// If there's no wait function, then reject the promise.
|
197 |
+
$this->reject('Cannot wait on a promise that has ' . 'no internal wait function. You must provide a wait ' . 'function when constructing the promise to be able to ' . 'wait on a promise.');
|
|
|
|
|
|
|
198 |
}
|
199 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::queue()->run();
|
|
|
|
|
200 |
/** @psalm-suppress RedundantCondition */
|
201 |
if ($this->state === self::PENDING) {
|
202 |
$this->reject('Invoking the wait callback did not resolve the promise');
|
203 |
}
|
204 |
}
|
|
|
205 |
private function invokeWaitFn()
|
206 |
{
|
207 |
try {
|
208 |
$wfn = $this->waitFn;
|
209 |
$this->waitFn = null;
|
210 |
+
$wfn(\true);
|
211 |
} catch (\Exception $reason) {
|
212 |
if ($this->state === self::PENDING) {
|
213 |
// The promise has not been resolved yet, so reject the promise
|
220 |
}
|
221 |
}
|
222 |
}
|
|
|
223 |
private function invokeWaitList()
|
224 |
{
|
225 |
$waitList = $this->waitList;
|
226 |
$this->waitList = null;
|
|
|
227 |
foreach ($waitList as $result) {
|
228 |
do {
|
229 |
$result->waitIfPending();
|
230 |
$result = $result->result;
|
231 |
+
} while ($result instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise);
|
232 |
+
if ($result instanceof \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface) {
|
233 |
+
$result->wait(\false);
|
|
|
234 |
}
|
235 |
}
|
236 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/PromiseInterface.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise represents the eventual result of an asynchronous operation.
|
@@ -16,7 +16,6 @@ interface PromiseInterface
|
|
16 |
const PENDING = 'pending';
|
17 |
const FULFILLED = 'fulfilled';
|
18 |
const REJECTED = 'rejected';
|
19 |
-
|
20 |
/**
|
21 |
* Appends fulfillment and rejection handlers to the promise, and returns
|
22 |
* a new promise resolving to the return value of the called handler.
|
@@ -26,11 +25,7 @@ interface PromiseInterface
|
|
26 |
*
|
27 |
* @return PromiseInterface
|
28 |
*/
|
29 |
-
public function then(
|
30 |
-
callable $onFulfilled = null,
|
31 |
-
callable $onRejected = null
|
32 |
-
);
|
33 |
-
|
34 |
/**
|
35 |
* Appends a rejection handler callback to the promise, and returns a new
|
36 |
* promise resolving to the return value of the callback if it is called,
|
@@ -42,7 +37,6 @@ interface PromiseInterface
|
|
42 |
* @return PromiseInterface
|
43 |
*/
|
44 |
public function otherwise(callable $onRejected);
|
45 |
-
|
46 |
/**
|
47 |
* Get the state of the promise ("pending", "rejected", or "fulfilled").
|
48 |
*
|
@@ -52,7 +46,6 @@ interface PromiseInterface
|
|
52 |
* @return string
|
53 |
*/
|
54 |
public function getState();
|
55 |
-
|
56 |
/**
|
57 |
* Resolve the promise with the given value.
|
58 |
*
|
@@ -61,7 +54,6 @@ interface PromiseInterface
|
|
61 |
* @throws \RuntimeException if the promise is already resolved.
|
62 |
*/
|
63 |
public function resolve($value);
|
64 |
-
|
65 |
/**
|
66 |
* Reject the promise with the given reason.
|
67 |
*
|
@@ -70,14 +62,12 @@ interface PromiseInterface
|
|
70 |
* @throws \RuntimeException if the promise is already resolved.
|
71 |
*/
|
72 |
public function reject($reason);
|
73 |
-
|
74 |
/**
|
75 |
* Cancels the promise if possible.
|
76 |
*
|
77 |
* @link https://github.com/promises-aplus/cancellation-spec/issues/7
|
78 |
*/
|
79 |
public function cancel();
|
80 |
-
|
81 |
/**
|
82 |
* Waits until the promise completes if possible.
|
83 |
*
|
@@ -93,5 +83,5 @@ interface PromiseInterface
|
|
93 |
* @throws \LogicException if the promise has no wait function or if the
|
94 |
* promise does not settle after waiting.
|
95 |
*/
|
96 |
-
public function wait($unwrap = true);
|
97 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise represents the eventual result of an asynchronous operation.
|
16 |
const PENDING = 'pending';
|
17 |
const FULFILLED = 'fulfilled';
|
18 |
const REJECTED = 'rejected';
|
|
|
19 |
/**
|
20 |
* Appends fulfillment and rejection handlers to the promise, and returns
|
21 |
* a new promise resolving to the return value of the called handler.
|
25 |
*
|
26 |
* @return PromiseInterface
|
27 |
*/
|
28 |
+
public function then(callable $onFulfilled = null, callable $onRejected = null);
|
|
|
|
|
|
|
|
|
29 |
/**
|
30 |
* Appends a rejection handler callback to the promise, and returns a new
|
31 |
* promise resolving to the return value of the callback if it is called,
|
37 |
* @return PromiseInterface
|
38 |
*/
|
39 |
public function otherwise(callable $onRejected);
|
|
|
40 |
/**
|
41 |
* Get the state of the promise ("pending", "rejected", or "fulfilled").
|
42 |
*
|
46 |
* @return string
|
47 |
*/
|
48 |
public function getState();
|
|
|
49 |
/**
|
50 |
* Resolve the promise with the given value.
|
51 |
*
|
54 |
* @throws \RuntimeException if the promise is already resolved.
|
55 |
*/
|
56 |
public function resolve($value);
|
|
|
57 |
/**
|
58 |
* Reject the promise with the given reason.
|
59 |
*
|
62 |
* @throws \RuntimeException if the promise is already resolved.
|
63 |
*/
|
64 |
public function reject($reason);
|
|
|
65 |
/**
|
66 |
* Cancels the promise if possible.
|
67 |
*
|
68 |
* @link https://github.com/promises-aplus/cancellation-spec/issues/7
|
69 |
*/
|
70 |
public function cancel();
|
|
|
71 |
/**
|
72 |
* Waits until the promise completes if possible.
|
73 |
*
|
83 |
* @throws \LogicException if the promise has no wait function or if the
|
84 |
* promise does not settle after waiting.
|
85 |
*/
|
86 |
+
public function wait($unwrap = \true);
|
87 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/PromisorInterface.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Interface used with classes that return a promise.
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Interface used with classes that return a promise.
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/RejectedPromise.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise that has been rejected.
|
@@ -8,35 +8,27 @@ namespace GuzzleHttp\Promise;
|
|
8 |
* Thenning off of this promise will invoke the onRejected callback
|
9 |
* immediately and ignore other callbacks.
|
10 |
*/
|
11 |
-
class RejectedPromise implements PromiseInterface
|
12 |
{
|
13 |
private $reason;
|
14 |
-
|
15 |
public function __construct($reason)
|
16 |
{
|
17 |
-
if (is_object($reason) && method_exists($reason, 'then')) {
|
18 |
-
throw new \InvalidArgumentException(
|
19 |
-
'You cannot create a RejectedPromise with a promise.'
|
20 |
-
);
|
21 |
}
|
22 |
-
|
23 |
$this->reason = $reason;
|
24 |
}
|
25 |
-
|
26 |
-
|
27 |
-
callable $onFulfilled = null,
|
28 |
-
callable $onRejected = null
|
29 |
-
) {
|
30 |
// If there's no onRejected callback then just return self.
|
31 |
if (!$onRejected) {
|
32 |
return $this;
|
33 |
}
|
34 |
-
|
35 |
-
$queue = Utils::queue();
|
36 |
$reason = $this->reason;
|
37 |
-
$p = new Promise([$queue, 'run']);
|
38 |
-
$queue->add(static function () use
|
39 |
-
if (Is::pending($p)) {
|
40 |
try {
|
41 |
// Return a resolved promise if onRejected does not throw.
|
42 |
$p->resolve($onRejected($reason));
|
@@ -49,41 +41,33 @@ class RejectedPromise implements PromiseInterface
|
|
49 |
}
|
50 |
}
|
51 |
});
|
52 |
-
|
53 |
return $p;
|
54 |
}
|
55 |
-
|
56 |
public function otherwise(callable $onRejected)
|
57 |
{
|
58 |
return $this->then(null, $onRejected);
|
59 |
}
|
60 |
-
|
61 |
-
public function wait($unwrap = true, $defaultDelivery = null)
|
62 |
{
|
63 |
if ($unwrap) {
|
64 |
-
throw Create::exceptionFor($this->reason);
|
65 |
}
|
66 |
-
|
67 |
return null;
|
68 |
}
|
69 |
-
|
70 |
public function getState()
|
71 |
{
|
72 |
return self::REJECTED;
|
73 |
}
|
74 |
-
|
75 |
public function resolve($value)
|
76 |
{
|
77 |
throw new \LogicException("Cannot resolve a rejected promise");
|
78 |
}
|
79 |
-
|
80 |
public function reject($reason)
|
81 |
{
|
82 |
if ($reason !== $this->reason) {
|
83 |
throw new \LogicException("Cannot reject a rejected promise");
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
public function cancel()
|
88 |
{
|
89 |
// pass
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A promise that has been rejected.
|
8 |
* Thenning off of this promise will invoke the onRejected callback
|
9 |
* immediately and ignore other callbacks.
|
10 |
*/
|
11 |
+
class RejectedPromise implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface
|
12 |
{
|
13 |
private $reason;
|
|
|
14 |
public function __construct($reason)
|
15 |
{
|
16 |
+
if (\is_object($reason) && \method_exists($reason, 'then')) {
|
17 |
+
throw new \InvalidArgumentException('You cannot create a RejectedPromise with a promise.');
|
|
|
|
|
18 |
}
|
|
|
19 |
$this->reason = $reason;
|
20 |
}
|
21 |
+
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
22 |
+
{
|
|
|
|
|
|
|
23 |
// If there's no onRejected callback then just return self.
|
24 |
if (!$onRejected) {
|
25 |
return $this;
|
26 |
}
|
27 |
+
$queue = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::queue();
|
|
|
28 |
$reason = $this->reason;
|
29 |
+
$p = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
30 |
+
$queue->add(static function () use($p, $reason, $onRejected) {
|
31 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::pending($p)) {
|
32 |
try {
|
33 |
// Return a resolved promise if onRejected does not throw.
|
34 |
$p->resolve($onRejected($reason));
|
41 |
}
|
42 |
}
|
43 |
});
|
|
|
44 |
return $p;
|
45 |
}
|
|
|
46 |
public function otherwise(callable $onRejected)
|
47 |
{
|
48 |
return $this->then(null, $onRejected);
|
49 |
}
|
50 |
+
public function wait($unwrap = \true, $defaultDelivery = null)
|
|
|
51 |
{
|
52 |
if ($unwrap) {
|
53 |
+
throw \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::exceptionFor($this->reason);
|
54 |
}
|
|
|
55 |
return null;
|
56 |
}
|
|
|
57 |
public function getState()
|
58 |
{
|
59 |
return self::REJECTED;
|
60 |
}
|
|
|
61 |
public function resolve($value)
|
62 |
{
|
63 |
throw new \LogicException("Cannot resolve a rejected promise");
|
64 |
}
|
|
|
65 |
public function reject($reason)
|
66 |
{
|
67 |
if ($reason !== $this->reason) {
|
68 |
throw new \LogicException("Cannot reject a rejected promise");
|
69 |
}
|
70 |
}
|
|
|
71 |
public function cancel()
|
72 |
{
|
73 |
// pass
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/RejectionException.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A special exception that is thrown when waiting on a rejected promise.
|
@@ -11,7 +11,6 @@ class RejectionException extends \RuntimeException
|
|
11 |
{
|
12 |
/** @var mixed Rejection reason. */
|
13 |
private $reason;
|
14 |
-
|
15 |
/**
|
16 |
* @param mixed $reason Rejection reason.
|
17 |
* @param string $description Optional description
|
@@ -19,23 +18,16 @@ class RejectionException extends \RuntimeException
|
|
19 |
public function __construct($reason, $description = null)
|
20 |
{
|
21 |
$this->reason = $reason;
|
22 |
-
|
23 |
$message = 'The promise was rejected';
|
24 |
-
|
25 |
if ($description) {
|
26 |
$message .= ' with reason: ' . $description;
|
27 |
-
} elseif (is_string($reason)
|
28 |
-
|| (is_object($reason) && method_exists($reason, '__toString'))
|
29 |
-
) {
|
30 |
$message .= ' with reason: ' . $this->reason;
|
31 |
} elseif ($reason instanceof \JsonSerializable) {
|
32 |
-
$message .= ' with reason: '
|
33 |
-
. json_encode($this->reason, JSON_PRETTY_PRINT);
|
34 |
}
|
35 |
-
|
36 |
parent::__construct($message);
|
37 |
}
|
38 |
-
|
39 |
/**
|
40 |
* Returns the rejection reason.
|
41 |
*
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A special exception that is thrown when waiting on a rejected promise.
|
11 |
{
|
12 |
/** @var mixed Rejection reason. */
|
13 |
private $reason;
|
|
|
14 |
/**
|
15 |
* @param mixed $reason Rejection reason.
|
16 |
* @param string $description Optional description
|
18 |
public function __construct($reason, $description = null)
|
19 |
{
|
20 |
$this->reason = $reason;
|
|
|
21 |
$message = 'The promise was rejected';
|
|
|
22 |
if ($description) {
|
23 |
$message .= ' with reason: ' . $description;
|
24 |
+
} elseif (\is_string($reason) || \is_object($reason) && \method_exists($reason, '__toString')) {
|
|
|
|
|
25 |
$message .= ' with reason: ' . $this->reason;
|
26 |
} elseif ($reason instanceof \JsonSerializable) {
|
27 |
+
$message .= ' with reason: ' . \json_encode($this->reason, \JSON_PRETTY_PRINT);
|
|
|
28 |
}
|
|
|
29 |
parent::__construct($message);
|
30 |
}
|
|
|
31 |
/**
|
32 |
* Returns the rejection reason.
|
33 |
*
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/TaskQueue.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A task queue that executes tasks in a FIFO order.
|
@@ -11,44 +11,39 @@ namespace GuzzleHttp\Promise;
|
|
11 |
*
|
12 |
* GuzzleHttp\Promise\Utils::queue()->run();
|
13 |
*/
|
14 |
-
class TaskQueue implements TaskQueueInterface
|
15 |
{
|
16 |
-
private $enableShutdown = true;
|
17 |
private $queue = [];
|
18 |
-
|
19 |
-
public function __construct($withShutdown = true)
|
20 |
{
|
21 |
if ($withShutdown) {
|
22 |
-
register_shutdown_function(function () {
|
23 |
if ($this->enableShutdown) {
|
24 |
// Only run the tasks if an E_ERROR didn't occur.
|
25 |
-
$err = error_get_last();
|
26 |
-
if (!$err ||
|
27 |
$this->run();
|
28 |
}
|
29 |
}
|
30 |
});
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
public function isEmpty()
|
35 |
{
|
36 |
return !$this->queue;
|
37 |
}
|
38 |
-
|
39 |
public function add(callable $task)
|
40 |
{
|
41 |
$this->queue[] = $task;
|
42 |
}
|
43 |
-
|
44 |
public function run()
|
45 |
{
|
46 |
-
while ($task = array_shift($this->queue)) {
|
47 |
/** @var callable $task */
|
48 |
$task();
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
/**
|
53 |
* The task queue will be run and exhausted by default when the process
|
54 |
* exits IFF the exit is not the result of a PHP E_ERROR error.
|
@@ -62,6 +57,6 @@ class TaskQueue implements TaskQueueInterface
|
|
62 |
*/
|
63 |
public function disableShutdown()
|
64 |
{
|
65 |
-
$this->enableShutdown = false;
|
66 |
}
|
67 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* A task queue that executes tasks in a FIFO order.
|
11 |
*
|
12 |
* GuzzleHttp\Promise\Utils::queue()->run();
|
13 |
*/
|
14 |
+
class TaskQueue implements \PixelCaffeine\Dependencies\GuzzleHttp\Promise\TaskQueueInterface
|
15 |
{
|
16 |
+
private $enableShutdown = \true;
|
17 |
private $queue = [];
|
18 |
+
public function __construct($withShutdown = \true)
|
|
|
19 |
{
|
20 |
if ($withShutdown) {
|
21 |
+
\register_shutdown_function(function () {
|
22 |
if ($this->enableShutdown) {
|
23 |
// Only run the tasks if an E_ERROR didn't occur.
|
24 |
+
$err = \error_get_last();
|
25 |
+
if (!$err || $err['type'] ^ \E_ERROR) {
|
26 |
$this->run();
|
27 |
}
|
28 |
}
|
29 |
});
|
30 |
}
|
31 |
}
|
|
|
32 |
public function isEmpty()
|
33 |
{
|
34 |
return !$this->queue;
|
35 |
}
|
|
|
36 |
public function add(callable $task)
|
37 |
{
|
38 |
$this->queue[] = $task;
|
39 |
}
|
|
|
40 |
public function run()
|
41 |
{
|
42 |
+
while ($task = \array_shift($this->queue)) {
|
43 |
/** @var callable $task */
|
44 |
$task();
|
45 |
}
|
46 |
}
|
|
|
47 |
/**
|
48 |
* The task queue will be run and exhausted by default when the process
|
49 |
* exits IFF the exit is not the result of a PHP E_ERROR error.
|
57 |
*/
|
58 |
public function disableShutdown()
|
59 |
{
|
60 |
+
$this->enableShutdown = \false;
|
61 |
}
|
62 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/TaskQueueInterface.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
interface TaskQueueInterface
|
6 |
{
|
@@ -10,13 +10,11 @@ interface TaskQueueInterface
|
|
10 |
* @return bool
|
11 |
*/
|
12 |
public function isEmpty();
|
13 |
-
|
14 |
/**
|
15 |
* Adds a task to the queue that will be executed the next time run is
|
16 |
* called.
|
17 |
*/
|
18 |
public function add(callable $task);
|
19 |
-
|
20 |
/**
|
21 |
* Execute all of the pending task in the queue.
|
22 |
*/
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
interface TaskQueueInterface
|
6 |
{
|
10 |
* @return bool
|
11 |
*/
|
12 |
public function isEmpty();
|
|
|
13 |
/**
|
14 |
* Adds a task to the queue that will be executed the next time run is
|
15 |
* called.
|
16 |
*/
|
17 |
public function add(callable $task);
|
|
|
18 |
/**
|
19 |
* Execute all of the pending task in the queue.
|
20 |
*/
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/Utils.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
final class Utils
|
6 |
{
|
@@ -21,19 +21,16 @@ final class Utils
|
|
21 |
*
|
22 |
* @return TaskQueueInterface
|
23 |
*/
|
24 |
-
public static function queue(TaskQueueInterface $assign = null)
|
25 |
{
|
26 |
static $queue;
|
27 |
-
|
28 |
if ($assign) {
|
29 |
$queue = $assign;
|
30 |
} elseif (!$queue) {
|
31 |
-
$queue = new TaskQueue();
|
32 |
}
|
33 |
-
|
34 |
return $queue;
|
35 |
}
|
36 |
-
|
37 |
/**
|
38 |
* Adds a function to run in the task queue when it is next `run()` and
|
39 |
* returns a promise that is fulfilled or rejected with the result.
|
@@ -45,8 +42,8 @@ final class Utils
|
|
45 |
public static function task(callable $task)
|
46 |
{
|
47 |
$queue = self::queue();
|
48 |
-
$promise = new Promise([$queue, 'run']);
|
49 |
-
$queue->add(function () use
|
50 |
try {
|
51 |
$promise->resolve($task());
|
52 |
} catch (\Throwable $e) {
|
@@ -55,10 +52,8 @@ final class Utils
|
|
55 |
$promise->reject($e);
|
56 |
}
|
57 |
});
|
58 |
-
|
59 |
return $promise;
|
60 |
}
|
61 |
-
|
62 |
/**
|
63 |
* Synchronously waits on a promise to resolve and returns an inspection
|
64 |
* state array.
|
@@ -73,22 +68,18 @@ final class Utils
|
|
73 |
*
|
74 |
* @return array
|
75 |
*/
|
76 |
-
public static function inspect(PromiseInterface $promise)
|
77 |
{
|
78 |
try {
|
79 |
-
return [
|
80 |
-
|
81 |
-
|
82 |
-
];
|
83 |
-
} catch (RejectionException $e) {
|
84 |
-
return ['state' => PromiseInterface::REJECTED, 'reason' => $e->getReason()];
|
85 |
} catch (\Throwable $e) {
|
86 |
-
return ['state' => PromiseInterface::REJECTED, 'reason' => $e];
|
87 |
} catch (\Exception $e) {
|
88 |
-
return ['state' => PromiseInterface::REJECTED, 'reason' => $e];
|
89 |
}
|
90 |
}
|
91 |
-
|
92 |
/**
|
93 |
* Waits on all of the provided promises, but does not unwrap rejected
|
94 |
* promises as thrown exception.
|
@@ -107,10 +98,8 @@ final class Utils
|
|
107 |
foreach ($promises as $key => $promise) {
|
108 |
$results[$key] = inspect($promise);
|
109 |
}
|
110 |
-
|
111 |
return $results;
|
112 |
}
|
113 |
-
|
114 |
/**
|
115 |
* Waits on all of the provided promises and returns the fulfilled values.
|
116 |
*
|
@@ -131,10 +120,8 @@ final class Utils
|
|
131 |
foreach ($promises as $key => $promise) {
|
132 |
$results[$key] = $promise->wait();
|
133 |
}
|
134 |
-
|
135 |
return $results;
|
136 |
}
|
137 |
-
|
138 |
/**
|
139 |
* Given an array of promises, return a promise that is fulfilled when all
|
140 |
* the items in the array are fulfilled.
|
@@ -148,36 +135,29 @@ final class Utils
|
|
148 |
*
|
149 |
* @return PromiseInterface
|
150 |
*/
|
151 |
-
public static function all($promises, $recursive = false)
|
152 |
{
|
153 |
$results = [];
|
154 |
-
$promise = Each::of(
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
$aggregate->reject($reason);
|
161 |
-
}
|
162 |
-
)->then(function () use (&$results) {
|
163 |
-
ksort($results);
|
164 |
return $results;
|
165 |
});
|
166 |
-
|
167 |
-
|
168 |
-
$promise = $promise->then(function ($results) use ($recursive, &$promises) {
|
169 |
foreach ($promises as $promise) {
|
170 |
-
if (Is::pending($promise)) {
|
171 |
return self::all($promises, $recursive);
|
172 |
}
|
173 |
}
|
174 |
return $results;
|
175 |
});
|
176 |
}
|
177 |
-
|
178 |
return $promise;
|
179 |
}
|
180 |
-
|
181 |
/**
|
182 |
* Initiate a competitive race between multiple promises or values (values
|
183 |
* will become immediately fulfilled promises).
|
@@ -198,35 +178,24 @@ final class Utils
|
|
198 |
{
|
199 |
$results = [];
|
200 |
$rejections = [];
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
function ($value, $idx, PromiseInterface $p) use (&$results, $count) {
|
205 |
-
if (Is::settled($p)) {
|
206 |
-
return;
|
207 |
-
}
|
208 |
-
$results[$idx] = $value;
|
209 |
-
if (count($results) >= $count) {
|
210 |
-
$p->resolve(null);
|
211 |
-
}
|
212 |
-
},
|
213 |
-
function ($reason) use (&$rejections) {
|
214 |
-
$rejections[] = $reason;
|
215 |
}
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
throw new AggregateException(
|
220 |
-
'Not enough promises to fulfill count',
|
221 |
-
$rejections
|
222 |
-
);
|
223 |
-
}
|
224 |
-
ksort($results);
|
225 |
-
return array_values($results);
|
226 |
}
|
227 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
-
|
230 |
/**
|
231 |
* Like some(), with 1 as count. However, if the promise fulfills, the
|
232 |
* fulfillment value is not an array of 1 but the value directly.
|
@@ -241,7 +210,6 @@ final class Utils
|
|
241 |
return $values[0];
|
242 |
});
|
243 |
}
|
244 |
-
|
245 |
/**
|
246 |
* Returns a promise that is fulfilled when all of the provided promises have
|
247 |
* been fulfilled or rejected.
|
@@ -257,17 +225,12 @@ final class Utils
|
|
257 |
public static function settle($promises)
|
258 |
{
|
259 |
$results = [];
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
function ($reason, $idx) use (&$results) {
|
267 |
-
$results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason];
|
268 |
-
}
|
269 |
-
)->then(function () use (&$results) {
|
270 |
-
ksort($results);
|
271 |
return $results;
|
272 |
});
|
273 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
final class Utils
|
6 |
{
|
21 |
*
|
22 |
* @return TaskQueueInterface
|
23 |
*/
|
24 |
+
public static function queue(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
25 |
{
|
26 |
static $queue;
|
|
|
27 |
if ($assign) {
|
28 |
$queue = $assign;
|
29 |
} elseif (!$queue) {
|
30 |
+
$queue = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\TaskQueue();
|
31 |
}
|
|
|
32 |
return $queue;
|
33 |
}
|
|
|
34 |
/**
|
35 |
* Adds a function to run in the task queue when it is next `run()` and
|
36 |
* returns a promise that is fulfilled or rejected with the result.
|
42 |
public static function task(callable $task)
|
43 |
{
|
44 |
$queue = self::queue();
|
45 |
+
$promise = new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
46 |
+
$queue->add(function () use($task, $promise) {
|
47 |
try {
|
48 |
$promise->resolve($task());
|
49 |
} catch (\Throwable $e) {
|
52 |
$promise->reject($e);
|
53 |
}
|
54 |
});
|
|
|
55 |
return $promise;
|
56 |
}
|
|
|
57 |
/**
|
58 |
* Synchronously waits on a promise to resolve and returns an inspection
|
59 |
* state array.
|
68 |
*
|
69 |
* @return array
|
70 |
*/
|
71 |
+
public static function inspect(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
72 |
{
|
73 |
try {
|
74 |
+
return ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $promise->wait()];
|
75 |
+
} catch (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\RejectionException $e) {
|
76 |
+
return ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e->getReason()];
|
|
|
|
|
|
|
77 |
} catch (\Throwable $e) {
|
78 |
+
return ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
79 |
} catch (\Exception $e) {
|
80 |
+
return ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
81 |
}
|
82 |
}
|
|
|
83 |
/**
|
84 |
* Waits on all of the provided promises, but does not unwrap rejected
|
85 |
* promises as thrown exception.
|
98 |
foreach ($promises as $key => $promise) {
|
99 |
$results[$key] = inspect($promise);
|
100 |
}
|
|
|
101 |
return $results;
|
102 |
}
|
|
|
103 |
/**
|
104 |
* Waits on all of the provided promises and returns the fulfilled values.
|
105 |
*
|
120 |
foreach ($promises as $key => $promise) {
|
121 |
$results[$key] = $promise->wait();
|
122 |
}
|
|
|
123 |
return $results;
|
124 |
}
|
|
|
125 |
/**
|
126 |
* Given an array of promises, return a promise that is fulfilled when all
|
127 |
* the items in the array are fulfilled.
|
135 |
*
|
136 |
* @return PromiseInterface
|
137 |
*/
|
138 |
+
public static function all($promises, $recursive = \false)
|
139 |
{
|
140 |
$results = [];
|
141 |
+
$promise = \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
142 |
+
$results[$idx] = $value;
|
143 |
+
}, function ($reason, $idx, \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Promise $aggregate) {
|
144 |
+
$aggregate->reject($reason);
|
145 |
+
})->then(function () use(&$results) {
|
146 |
+
\ksort($results);
|
|
|
|
|
|
|
|
|
147 |
return $results;
|
148 |
});
|
149 |
+
if (\true === $recursive) {
|
150 |
+
$promise = $promise->then(function ($results) use($recursive, &$promises) {
|
|
|
151 |
foreach ($promises as $promise) {
|
152 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::pending($promise)) {
|
153 |
return self::all($promises, $recursive);
|
154 |
}
|
155 |
}
|
156 |
return $results;
|
157 |
});
|
158 |
}
|
|
|
159 |
return $promise;
|
160 |
}
|
|
|
161 |
/**
|
162 |
* Initiate a competitive race between multiple promises or values (values
|
163 |
* will become immediately fulfilled promises).
|
178 |
{
|
179 |
$results = [];
|
180 |
$rejections = [];
|
181 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx, \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $p) use(&$results, $count) {
|
182 |
+
if (\PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::settled($p)) {
|
183 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
+
$results[$idx] = $value;
|
186 |
+
if (\count($results) >= $count) {
|
187 |
+
$p->resolve(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
+
}, function ($reason) use(&$rejections) {
|
190 |
+
$rejections[] = $reason;
|
191 |
+
})->then(function () use(&$results, &$rejections, $count) {
|
192 |
+
if (\count($results) !== $count) {
|
193 |
+
throw new \PixelCaffeine\Dependencies\GuzzleHttp\Promise\AggregateException('Not enough promises to fulfill count', $rejections);
|
194 |
+
}
|
195 |
+
\ksort($results);
|
196 |
+
return \array_values($results);
|
197 |
+
});
|
198 |
}
|
|
|
199 |
/**
|
200 |
* Like some(), with 1 as count. However, if the promise fulfills, the
|
201 |
* fulfillment value is not an array of 1 but the value directly.
|
210 |
return $values[0];
|
211 |
});
|
212 |
}
|
|
|
213 |
/**
|
214 |
* Returns a promise that is fulfilled when all of the provided promises have
|
215 |
* been fulfilled or rejected.
|
225 |
public static function settle($promises)
|
226 |
{
|
227 |
$results = [];
|
228 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
229 |
+
$results[$idx] = ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $value];
|
230 |
+
}, function ($reason, $idx) use(&$results) {
|
231 |
+
$results[$idx] = ['state' => \PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $reason];
|
232 |
+
})->then(function () use(&$results) {
|
233 |
+
\ksort($results);
|
|
|
|
|
|
|
|
|
|
|
234 |
return $results;
|
235 |
});
|
236 |
}
|
{vendor → third-party/vendor}/guzzlehttp/promises/src/functions.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Get the global task queue used for promise resolution.
|
@@ -21,11 +21,10 @@ namespace GuzzleHttp\Promise;
|
|
21 |
*
|
22 |
* @deprecated queue will be removed in guzzlehttp/promises:2.0. Use Utils::queue instead.
|
23 |
*/
|
24 |
-
function queue(TaskQueueInterface $assign = null)
|
25 |
{
|
26 |
-
return Utils::queue($assign);
|
27 |
}
|
28 |
-
|
29 |
/**
|
30 |
* Adds a function to run in the task queue when it is next `run()` and returns
|
31 |
* a promise that is fulfilled or rejected with the result.
|
@@ -38,9 +37,8 @@ function queue(TaskQueueInterface $assign = null)
|
|
38 |
*/
|
39 |
function task(callable $task)
|
40 |
{
|
41 |
-
return Utils::task($task);
|
42 |
}
|
43 |
-
|
44 |
/**
|
45 |
* Creates a promise for a value if the value is not a promise.
|
46 |
*
|
@@ -52,9 +50,8 @@ function task(callable $task)
|
|
52 |
*/
|
53 |
function promise_for($value)
|
54 |
{
|
55 |
-
return Create::promiseFor($value);
|
56 |
}
|
57 |
-
|
58 |
/**
|
59 |
* Creates a rejected promise for a reason if the reason is not a promise. If
|
60 |
* the provided reason is a promise, then it is returned as-is.
|
@@ -67,9 +64,8 @@ function promise_for($value)
|
|
67 |
*/
|
68 |
function rejection_for($reason)
|
69 |
{
|
70 |
-
return Create::rejectionFor($reason);
|
71 |
}
|
72 |
-
|
73 |
/**
|
74 |
* Create an exception for a rejected promise value.
|
75 |
*
|
@@ -81,9 +77,8 @@ function rejection_for($reason)
|
|
81 |
*/
|
82 |
function exception_for($reason)
|
83 |
{
|
84 |
-
return Create::exceptionFor($reason);
|
85 |
}
|
86 |
-
|
87 |
/**
|
88 |
* Returns an iterator for the given value.
|
89 |
*
|
@@ -95,9 +90,8 @@ function exception_for($reason)
|
|
95 |
*/
|
96 |
function iter_for($value)
|
97 |
{
|
98 |
-
return Create::iterFor($value);
|
99 |
}
|
100 |
-
|
101 |
/**
|
102 |
* Synchronously waits on a promise to resolve and returns an inspection state
|
103 |
* array.
|
@@ -114,11 +108,10 @@ function iter_for($value)
|
|
114 |
*
|
115 |
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspect instead.
|
116 |
*/
|
117 |
-
function inspect(PromiseInterface $promise)
|
118 |
{
|
119 |
-
return Utils::inspect($promise);
|
120 |
}
|
121 |
-
|
122 |
/**
|
123 |
* Waits on all of the provided promises, but does not unwrap rejected promises
|
124 |
* as thrown exception.
|
@@ -135,9 +128,8 @@ function inspect(PromiseInterface $promise)
|
|
135 |
*/
|
136 |
function inspect_all($promises)
|
137 |
{
|
138 |
-
return Utils::inspectAll($promises);
|
139 |
}
|
140 |
-
|
141 |
/**
|
142 |
* Waits on all of the provided promises and returns the fulfilled values.
|
143 |
*
|
@@ -156,9 +148,8 @@ function inspect_all($promises)
|
|
156 |
*/
|
157 |
function unwrap($promises)
|
158 |
{
|
159 |
-
return Utils::unwrap($promises);
|
160 |
}
|
161 |
-
|
162 |
/**
|
163 |
* Given an array of promises, return a promise that is fulfilled when all the
|
164 |
* items in the array are fulfilled.
|
@@ -174,11 +165,10 @@ function unwrap($promises)
|
|
174 |
*
|
175 |
* @deprecated all will be removed in guzzlehttp/promises:2.0. Use Utils::all instead.
|
176 |
*/
|
177 |
-
function all($promises, $recursive = false)
|
178 |
{
|
179 |
-
return Utils::all($promises, $recursive);
|
180 |
}
|
181 |
-
|
182 |
/**
|
183 |
* Initiate a competitive race between multiple promises or values (values will
|
184 |
* become immediately fulfilled promises).
|
@@ -199,9 +189,8 @@ function all($promises, $recursive = false)
|
|
199 |
*/
|
200 |
function some($count, $promises)
|
201 |
{
|
202 |
-
return Utils::some($count, $promises);
|
203 |
}
|
204 |
-
|
205 |
/**
|
206 |
* Like some(), with 1 as count. However, if the promise fulfills, the
|
207 |
* fulfillment value is not an array of 1 but the value directly.
|
@@ -214,9 +203,8 @@ function some($count, $promises)
|
|
214 |
*/
|
215 |
function any($promises)
|
216 |
{
|
217 |
-
return Utils::any($promises);
|
218 |
}
|
219 |
-
|
220 |
/**
|
221 |
* Returns a promise that is fulfilled when all of the provided promises have
|
222 |
* been fulfilled or rejected.
|
@@ -233,9 +221,8 @@ function any($promises)
|
|
233 |
*/
|
234 |
function settle($promises)
|
235 |
{
|
236 |
-
return Utils::settle($promises);
|
237 |
}
|
238 |
-
|
239 |
/**
|
240 |
* Given an iterator that yields promises or values, returns a promise that is
|
241 |
* fulfilled with a null value when the iterator has been consumed or the
|
@@ -257,14 +244,10 @@ function settle($promises)
|
|
257 |
*
|
258 |
* @deprecated each will be removed in guzzlehttp/promises:2.0. Use Each::of instead.
|
259 |
*/
|
260 |
-
function each(
|
261 |
-
|
262 |
-
|
263 |
-
callable $onRejected = null
|
264 |
-
) {
|
265 |
-
return Each::of($iterable, $onFulfilled, $onRejected);
|
266 |
}
|
267 |
-
|
268 |
/**
|
269 |
* Like each, but only allows a certain number of outstanding promises at any
|
270 |
* given time.
|
@@ -282,15 +265,10 @@ function each(
|
|
282 |
*
|
283 |
* @deprecated each_limit will be removed in guzzlehttp/promises:2.0. Use Each::ofLimit instead.
|
284 |
*/
|
285 |
-
function each_limit(
|
286 |
-
|
287 |
-
$concurrency,
|
288 |
-
callable $onFulfilled = null,
|
289 |
-
callable $onRejected = null
|
290 |
-
) {
|
291 |
-
return Each::ofLimit($iterable, $concurrency, $onFulfilled, $onRejected);
|
292 |
}
|
293 |
-
|
294 |
/**
|
295 |
* Like each_limit, but ensures that no promise in the given $iterable argument
|
296 |
* is rejected. If any promise is rejected, then the aggregate promise is
|
@@ -304,14 +282,10 @@ function each_limit(
|
|
304 |
*
|
305 |
* @deprecated each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each::ofLimitAll instead.
|
306 |
*/
|
307 |
-
function each_limit_all(
|
308 |
-
|
309 |
-
$concurrency,
|
310 |
-
callable $onFulfilled = null
|
311 |
-
) {
|
312 |
-
return Each::ofLimitAll($iterable, $concurrency, $onFulfilled);
|
313 |
}
|
314 |
-
|
315 |
/**
|
316 |
* Returns true if a promise is fulfilled.
|
317 |
*
|
@@ -319,11 +293,10 @@ function each_limit_all(
|
|
319 |
*
|
320 |
* @deprecated is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is::fulfilled instead.
|
321 |
*/
|
322 |
-
function is_fulfilled(PromiseInterface $promise)
|
323 |
{
|
324 |
-
return Is::fulfilled($promise);
|
325 |
}
|
326 |
-
|
327 |
/**
|
328 |
* Returns true if a promise is rejected.
|
329 |
*
|
@@ -331,11 +304,10 @@ function is_fulfilled(PromiseInterface $promise)
|
|
331 |
*
|
332 |
* @deprecated is_rejected will be removed in guzzlehttp/promises:2.0. Use Is::rejected instead.
|
333 |
*/
|
334 |
-
function is_rejected(PromiseInterface $promise)
|
335 |
{
|
336 |
-
return Is::rejected($promise);
|
337 |
}
|
338 |
-
|
339 |
/**
|
340 |
* Returns true if a promise is fulfilled or rejected.
|
341 |
*
|
@@ -343,11 +315,10 @@ function is_rejected(PromiseInterface $promise)
|
|
343 |
*
|
344 |
* @deprecated is_settled will be removed in guzzlehttp/promises:2.0. Use Is::settled instead.
|
345 |
*/
|
346 |
-
function is_settled(PromiseInterface $promise)
|
347 |
{
|
348 |
-
return Is::settled($promise);
|
349 |
}
|
350 |
-
|
351 |
/**
|
352 |
* Create a new coroutine.
|
353 |
*
|
@@ -359,5 +330,5 @@ function is_settled(PromiseInterface $promise)
|
|
359 |
*/
|
360 |
function coroutine(callable $generatorFn)
|
361 |
{
|
362 |
-
return Coroutine::of($generatorFn);
|
363 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Promise;
|
4 |
|
5 |
/**
|
6 |
* Get the global task queue used for promise resolution.
|
21 |
*
|
22 |
* @deprecated queue will be removed in guzzlehttp/promises:2.0. Use Utils::queue instead.
|
23 |
*/
|
24 |
+
function queue(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
25 |
{
|
26 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::queue($assign);
|
27 |
}
|
|
|
28 |
/**
|
29 |
* Adds a function to run in the task queue when it is next `run()` and returns
|
30 |
* a promise that is fulfilled or rejected with the result.
|
37 |
*/
|
38 |
function task(callable $task)
|
39 |
{
|
40 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::task($task);
|
41 |
}
|
|
|
42 |
/**
|
43 |
* Creates a promise for a value if the value is not a promise.
|
44 |
*
|
50 |
*/
|
51 |
function promise_for($value)
|
52 |
{
|
53 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::promiseFor($value);
|
54 |
}
|
|
|
55 |
/**
|
56 |
* Creates a rejected promise for a reason if the reason is not a promise. If
|
57 |
* the provided reason is a promise, then it is returned as-is.
|
64 |
*/
|
65 |
function rejection_for($reason)
|
66 |
{
|
67 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::rejectionFor($reason);
|
68 |
}
|
|
|
69 |
/**
|
70 |
* Create an exception for a rejected promise value.
|
71 |
*
|
77 |
*/
|
78 |
function exception_for($reason)
|
79 |
{
|
80 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::exceptionFor($reason);
|
81 |
}
|
|
|
82 |
/**
|
83 |
* Returns an iterator for the given value.
|
84 |
*
|
90 |
*/
|
91 |
function iter_for($value)
|
92 |
{
|
93 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Create::iterFor($value);
|
94 |
}
|
|
|
95 |
/**
|
96 |
* Synchronously waits on a promise to resolve and returns an inspection state
|
97 |
* array.
|
108 |
*
|
109 |
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspect instead.
|
110 |
*/
|
111 |
+
function inspect(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
112 |
{
|
113 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::inspect($promise);
|
114 |
}
|
|
|
115 |
/**
|
116 |
* Waits on all of the provided promises, but does not unwrap rejected promises
|
117 |
* as thrown exception.
|
128 |
*/
|
129 |
function inspect_all($promises)
|
130 |
{
|
131 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::inspectAll($promises);
|
132 |
}
|
|
|
133 |
/**
|
134 |
* Waits on all of the provided promises and returns the fulfilled values.
|
135 |
*
|
148 |
*/
|
149 |
function unwrap($promises)
|
150 |
{
|
151 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::unwrap($promises);
|
152 |
}
|
|
|
153 |
/**
|
154 |
* Given an array of promises, return a promise that is fulfilled when all the
|
155 |
* items in the array are fulfilled.
|
165 |
*
|
166 |
* @deprecated all will be removed in guzzlehttp/promises:2.0. Use Utils::all instead.
|
167 |
*/
|
168 |
+
function all($promises, $recursive = \false)
|
169 |
{
|
170 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::all($promises, $recursive);
|
171 |
}
|
|
|
172 |
/**
|
173 |
* Initiate a competitive race between multiple promises or values (values will
|
174 |
* become immediately fulfilled promises).
|
189 |
*/
|
190 |
function some($count, $promises)
|
191 |
{
|
192 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::some($count, $promises);
|
193 |
}
|
|
|
194 |
/**
|
195 |
* Like some(), with 1 as count. However, if the promise fulfills, the
|
196 |
* fulfillment value is not an array of 1 but the value directly.
|
203 |
*/
|
204 |
function any($promises)
|
205 |
{
|
206 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::any($promises);
|
207 |
}
|
|
|
208 |
/**
|
209 |
* Returns a promise that is fulfilled when all of the provided promises have
|
210 |
* been fulfilled or rejected.
|
221 |
*/
|
222 |
function settle($promises)
|
223 |
{
|
224 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Utils::settle($promises);
|
225 |
}
|
|
|
226 |
/**
|
227 |
* Given an iterator that yields promises or values, returns a promise that is
|
228 |
* fulfilled with a null value when the iterator has been consumed or the
|
244 |
*
|
245 |
* @deprecated each will be removed in guzzlehttp/promises:2.0. Use Each::of instead.
|
246 |
*/
|
247 |
+
function each($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
248 |
+
{
|
249 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::of($iterable, $onFulfilled, $onRejected);
|
|
|
|
|
|
|
250 |
}
|
|
|
251 |
/**
|
252 |
* Like each, but only allows a certain number of outstanding promises at any
|
253 |
* given time.
|
265 |
*
|
266 |
* @deprecated each_limit will be removed in guzzlehttp/promises:2.0. Use Each::ofLimit instead.
|
267 |
*/
|
268 |
+
function each_limit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
269 |
+
{
|
270 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::ofLimit($iterable, $concurrency, $onFulfilled, $onRejected);
|
|
|
|
|
|
|
|
|
271 |
}
|
|
|
272 |
/**
|
273 |
* Like each_limit, but ensures that no promise in the given $iterable argument
|
274 |
* is rejected. If any promise is rejected, then the aggregate promise is
|
282 |
*
|
283 |
* @deprecated each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each::ofLimitAll instead.
|
284 |
*/
|
285 |
+
function each_limit_all($iterable, $concurrency, callable $onFulfilled = null)
|
286 |
+
{
|
287 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Each::ofLimitAll($iterable, $concurrency, $onFulfilled);
|
|
|
|
|
|
|
288 |
}
|
|
|
289 |
/**
|
290 |
* Returns true if a promise is fulfilled.
|
291 |
*
|
293 |
*
|
294 |
* @deprecated is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is::fulfilled instead.
|
295 |
*/
|
296 |
+
function is_fulfilled(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
297 |
{
|
298 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::fulfilled($promise);
|
299 |
}
|
|
|
300 |
/**
|
301 |
* Returns true if a promise is rejected.
|
302 |
*
|
304 |
*
|
305 |
* @deprecated is_rejected will be removed in guzzlehttp/promises:2.0. Use Is::rejected instead.
|
306 |
*/
|
307 |
+
function is_rejected(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
308 |
{
|
309 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::rejected($promise);
|
310 |
}
|
|
|
311 |
/**
|
312 |
* Returns true if a promise is fulfilled or rejected.
|
313 |
*
|
315 |
*
|
316 |
* @deprecated is_settled will be removed in guzzlehttp/promises:2.0. Use Is::settled instead.
|
317 |
*/
|
318 |
+
function is_settled(\PixelCaffeine\Dependencies\GuzzleHttp\Promise\PromiseInterface $promise)
|
319 |
{
|
320 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Is::settled($promise);
|
321 |
}
|
|
|
322 |
/**
|
323 |
* Create a new coroutine.
|
324 |
*
|
330 |
*/
|
331 |
function coroutine(callable $generatorFn)
|
332 |
{
|
333 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Promise\Coroutine::of($generatorFn);
|
334 |
}
|
third-party/vendor/guzzlehttp/promises/src/functions_include.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies;
|
4 |
+
|
5 |
+
// Don't redefine the functions if included multiple times.
|
6 |
+
if (!\function_exists('PixelCaffeine\\Dependencies\\GuzzleHttp\\Promise\\promise_for')) {
|
7 |
+
require __DIR__ . '/functions.php';
|
8 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/AppendStream.php
RENAMED
@@ -1,23 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Reads from multiple streams, one after the other.
|
9 |
*
|
10 |
* This is a read-only stream decorator.
|
11 |
*/
|
12 |
-
class AppendStream implements StreamInterface
|
13 |
{
|
14 |
/** @var StreamInterface[] Streams being decorated */
|
15 |
private $streams = [];
|
16 |
-
|
17 |
-
private $seekable = true;
|
18 |
private $current = 0;
|
19 |
private $pos = 0;
|
20 |
-
|
21 |
/**
|
22 |
* @param StreamInterface[] $streams Streams to decorate. Each stream must
|
23 |
* be readable.
|
@@ -28,7 +25,6 @@ class AppendStream implements StreamInterface
|
|
28 |
$this->addStream($stream);
|
29 |
}
|
30 |
}
|
31 |
-
|
32 |
public function __toString()
|
33 |
{
|
34 |
try {
|
@@ -38,7 +34,6 @@ class AppendStream implements StreamInterface
|
|
38 |
return '';
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
/**
|
43 |
* Add a stream to the AppendStream
|
44 |
*
|
@@ -46,25 +41,21 @@ class AppendStream implements StreamInterface
|
|
46 |
*
|
47 |
* @throws \InvalidArgumentException if the stream is not readable
|
48 |
*/
|
49 |
-
public function addStream(StreamInterface $stream)
|
50 |
{
|
51 |
if (!$stream->isReadable()) {
|
52 |
throw new \InvalidArgumentException('Each stream must be readable');
|
53 |
}
|
54 |
-
|
55 |
// The stream is only seekable if all streams are seekable
|
56 |
if (!$stream->isSeekable()) {
|
57 |
-
$this->seekable = false;
|
58 |
}
|
59 |
-
|
60 |
$this->streams[] = $stream;
|
61 |
}
|
62 |
-
|
63 |
public function getContents()
|
64 |
{
|
65 |
-
return Utils::copyToString($this);
|
66 |
}
|
67 |
-
|
68 |
/**
|
69 |
* Closes each attached stream.
|
70 |
*
|
@@ -73,15 +64,12 @@ class AppendStream implements StreamInterface
|
|
73 |
public function close()
|
74 |
{
|
75 |
$this->pos = $this->current = 0;
|
76 |
-
$this->seekable = true;
|
77 |
-
|
78 |
foreach ($this->streams as $stream) {
|
79 |
$stream->close();
|
80 |
}
|
81 |
-
|
82 |
$this->streams = [];
|
83 |
}
|
84 |
-
|
85 |
/**
|
86 |
* Detaches each attached stream.
|
87 |
*
|
@@ -92,22 +80,17 @@ class AppendStream implements StreamInterface
|
|
92 |
public function detach()
|
93 |
{
|
94 |
$this->pos = $this->current = 0;
|
95 |
-
$this->seekable = true;
|
96 |
-
|
97 |
foreach ($this->streams as $stream) {
|
98 |
$stream->detach();
|
99 |
}
|
100 |
-
|
101 |
$this->streams = [];
|
102 |
-
|
103 |
return null;
|
104 |
}
|
105 |
-
|
106 |
public function tell()
|
107 |
{
|
108 |
return $this->pos;
|
109 |
}
|
110 |
-
|
111 |
/**
|
112 |
* Tries to calculate the size by adding the size of each stream.
|
113 |
*
|
@@ -119,7 +102,6 @@ class AppendStream implements StreamInterface
|
|
119 |
public function getSize()
|
120 |
{
|
121 |
$size = 0;
|
122 |
-
|
123 |
foreach ($this->streams as $stream) {
|
124 |
$s = $stream->getSize();
|
125 |
if ($s === null) {
|
@@ -127,56 +109,45 @@ class AppendStream implements StreamInterface
|
|
127 |
}
|
128 |
$size += $s;
|
129 |
}
|
130 |
-
|
131 |
return $size;
|
132 |
}
|
133 |
-
|
134 |
public function eof()
|
135 |
{
|
136 |
-
return !$this->streams ||
|
137 |
-
($this->current >= count($this->streams) - 1 &&
|
138 |
-
$this->streams[$this->current]->eof());
|
139 |
}
|
140 |
-
|
141 |
public function rewind()
|
142 |
{
|
143 |
$this->seek(0);
|
144 |
}
|
145 |
-
|
146 |
/**
|
147 |
* Attempts to seek to the given position. Only supports SEEK_SET.
|
148 |
*
|
149 |
* {@inheritdoc}
|
150 |
*/
|
151 |
-
public function seek($offset, $whence = SEEK_SET)
|
152 |
{
|
153 |
if (!$this->seekable) {
|
154 |
throw new \RuntimeException('This AppendStream is not seekable');
|
155 |
-
} elseif ($whence !== SEEK_SET) {
|
156 |
throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
|
157 |
}
|
158 |
-
|
159 |
$this->pos = $this->current = 0;
|
160 |
-
|
161 |
// Rewind each stream
|
162 |
foreach ($this->streams as $i => $stream) {
|
163 |
try {
|
164 |
$stream->rewind();
|
165 |
} catch (\Exception $e) {
|
166 |
-
throw new \RuntimeException('Unable to seek stream '
|
167 |
-
. $i . ' of the AppendStream', 0, $e);
|
168 |
}
|
169 |
}
|
170 |
-
|
171 |
// Seek to the actual position by reading from each stream
|
172 |
while ($this->pos < $offset && !$this->eof()) {
|
173 |
-
$result = $this->read(min(8096, $offset - $this->pos));
|
174 |
if ($result === '') {
|
175 |
break;
|
176 |
}
|
177 |
}
|
178 |
}
|
179 |
-
|
180 |
/**
|
181 |
* Reads from all of the appended streams until the length is met or EOF.
|
182 |
*
|
@@ -185,58 +156,46 @@ class AppendStream implements StreamInterface
|
|
185 |
public function read($length)
|
186 |
{
|
187 |
$buffer = '';
|
188 |
-
$total = count($this->streams) - 1;
|
189 |
$remaining = $length;
|
190 |
-
$progressToNext = false;
|
191 |
-
|
192 |
while ($remaining > 0) {
|
193 |
-
|
194 |
// Progress to the next stream if needed.
|
195 |
if ($progressToNext || $this->streams[$this->current]->eof()) {
|
196 |
-
$progressToNext = false;
|
197 |
if ($this->current === $total) {
|
198 |
break;
|
199 |
}
|
200 |
$this->current++;
|
201 |
}
|
202 |
-
|
203 |
$result = $this->streams[$this->current]->read($remaining);
|
204 |
-
|
205 |
// Using a loose comparison here to match on '', false, and null
|
206 |
if ($result == null) {
|
207 |
-
$progressToNext = true;
|
208 |
continue;
|
209 |
}
|
210 |
-
|
211 |
$buffer .= $result;
|
212 |
-
$remaining = $length - strlen($buffer);
|
213 |
}
|
214 |
-
|
215 |
-
$this->pos += strlen($buffer);
|
216 |
-
|
217 |
return $buffer;
|
218 |
}
|
219 |
-
|
220 |
public function isReadable()
|
221 |
{
|
222 |
-
return true;
|
223 |
}
|
224 |
-
|
225 |
public function isWritable()
|
226 |
{
|
227 |
-
return false;
|
228 |
}
|
229 |
-
|
230 |
public function isSeekable()
|
231 |
{
|
232 |
return $this->seekable;
|
233 |
}
|
234 |
-
|
235 |
public function write($string)
|
236 |
{
|
237 |
throw new \RuntimeException('Cannot write to an AppendStream');
|
238 |
}
|
239 |
-
|
240 |
public function getMetadata($key = null)
|
241 |
{
|
242 |
return $key ? null : [];
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Reads from multiple streams, one after the other.
|
8 |
*
|
9 |
* This is a read-only stream decorator.
|
10 |
*/
|
11 |
+
class AppendStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
12 |
{
|
13 |
/** @var StreamInterface[] Streams being decorated */
|
14 |
private $streams = [];
|
15 |
+
private $seekable = \true;
|
|
|
16 |
private $current = 0;
|
17 |
private $pos = 0;
|
|
|
18 |
/**
|
19 |
* @param StreamInterface[] $streams Streams to decorate. Each stream must
|
20 |
* be readable.
|
25 |
$this->addStream($stream);
|
26 |
}
|
27 |
}
|
|
|
28 |
public function __toString()
|
29 |
{
|
30 |
try {
|
34 |
return '';
|
35 |
}
|
36 |
}
|
|
|
37 |
/**
|
38 |
* Add a stream to the AppendStream
|
39 |
*
|
41 |
*
|
42 |
* @throws \InvalidArgumentException if the stream is not readable
|
43 |
*/
|
44 |
+
public function addStream(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream)
|
45 |
{
|
46 |
if (!$stream->isReadable()) {
|
47 |
throw new \InvalidArgumentException('Each stream must be readable');
|
48 |
}
|
|
|
49 |
// The stream is only seekable if all streams are seekable
|
50 |
if (!$stream->isSeekable()) {
|
51 |
+
$this->seekable = \false;
|
52 |
}
|
|
|
53 |
$this->streams[] = $stream;
|
54 |
}
|
|
|
55 |
public function getContents()
|
56 |
{
|
57 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::copyToString($this);
|
58 |
}
|
|
|
59 |
/**
|
60 |
* Closes each attached stream.
|
61 |
*
|
64 |
public function close()
|
65 |
{
|
66 |
$this->pos = $this->current = 0;
|
67 |
+
$this->seekable = \true;
|
|
|
68 |
foreach ($this->streams as $stream) {
|
69 |
$stream->close();
|
70 |
}
|
|
|
71 |
$this->streams = [];
|
72 |
}
|
|
|
73 |
/**
|
74 |
* Detaches each attached stream.
|
75 |
*
|
80 |
public function detach()
|
81 |
{
|
82 |
$this->pos = $this->current = 0;
|
83 |
+
$this->seekable = \true;
|
|
|
84 |
foreach ($this->streams as $stream) {
|
85 |
$stream->detach();
|
86 |
}
|
|
|
87 |
$this->streams = [];
|
|
|
88 |
return null;
|
89 |
}
|
|
|
90 |
public function tell()
|
91 |
{
|
92 |
return $this->pos;
|
93 |
}
|
|
|
94 |
/**
|
95 |
* Tries to calculate the size by adding the size of each stream.
|
96 |
*
|
102 |
public function getSize()
|
103 |
{
|
104 |
$size = 0;
|
|
|
105 |
foreach ($this->streams as $stream) {
|
106 |
$s = $stream->getSize();
|
107 |
if ($s === null) {
|
109 |
}
|
110 |
$size += $s;
|
111 |
}
|
|
|
112 |
return $size;
|
113 |
}
|
|
|
114 |
public function eof()
|
115 |
{
|
116 |
+
return !$this->streams || $this->current >= \count($this->streams) - 1 && $this->streams[$this->current]->eof();
|
|
|
|
|
117 |
}
|
|
|
118 |
public function rewind()
|
119 |
{
|
120 |
$this->seek(0);
|
121 |
}
|
|
|
122 |
/**
|
123 |
* Attempts to seek to the given position. Only supports SEEK_SET.
|
124 |
*
|
125 |
* {@inheritdoc}
|
126 |
*/
|
127 |
+
public function seek($offset, $whence = \SEEK_SET)
|
128 |
{
|
129 |
if (!$this->seekable) {
|
130 |
throw new \RuntimeException('This AppendStream is not seekable');
|
131 |
+
} elseif ($whence !== \SEEK_SET) {
|
132 |
throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
|
133 |
}
|
|
|
134 |
$this->pos = $this->current = 0;
|
|
|
135 |
// Rewind each stream
|
136 |
foreach ($this->streams as $i => $stream) {
|
137 |
try {
|
138 |
$stream->rewind();
|
139 |
} catch (\Exception $e) {
|
140 |
+
throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e);
|
|
|
141 |
}
|
142 |
}
|
|
|
143 |
// Seek to the actual position by reading from each stream
|
144 |
while ($this->pos < $offset && !$this->eof()) {
|
145 |
+
$result = $this->read(\min(8096, $offset - $this->pos));
|
146 |
if ($result === '') {
|
147 |
break;
|
148 |
}
|
149 |
}
|
150 |
}
|
|
|
151 |
/**
|
152 |
* Reads from all of the appended streams until the length is met or EOF.
|
153 |
*
|
156 |
public function read($length)
|
157 |
{
|
158 |
$buffer = '';
|
159 |
+
$total = \count($this->streams) - 1;
|
160 |
$remaining = $length;
|
161 |
+
$progressToNext = \false;
|
|
|
162 |
while ($remaining > 0) {
|
|
|
163 |
// Progress to the next stream if needed.
|
164 |
if ($progressToNext || $this->streams[$this->current]->eof()) {
|
165 |
+
$progressToNext = \false;
|
166 |
if ($this->current === $total) {
|
167 |
break;
|
168 |
}
|
169 |
$this->current++;
|
170 |
}
|
|
|
171 |
$result = $this->streams[$this->current]->read($remaining);
|
|
|
172 |
// Using a loose comparison here to match on '', false, and null
|
173 |
if ($result == null) {
|
174 |
+
$progressToNext = \true;
|
175 |
continue;
|
176 |
}
|
|
|
177 |
$buffer .= $result;
|
178 |
+
$remaining = $length - \strlen($buffer);
|
179 |
}
|
180 |
+
$this->pos += \strlen($buffer);
|
|
|
|
|
181 |
return $buffer;
|
182 |
}
|
|
|
183 |
public function isReadable()
|
184 |
{
|
185 |
+
return \true;
|
186 |
}
|
|
|
187 |
public function isWritable()
|
188 |
{
|
189 |
+
return \false;
|
190 |
}
|
|
|
191 |
public function isSeekable()
|
192 |
{
|
193 |
return $this->seekable;
|
194 |
}
|
|
|
195 |
public function write($string)
|
196 |
{
|
197 |
throw new \RuntimeException('Cannot write to an AppendStream');
|
198 |
}
|
|
|
199 |
public function getMetadata($key = null)
|
200 |
{
|
201 |
return $key ? null : [];
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/BufferStream.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Provides a buffer stream that can be written to to fill a buffer, and read
|
9 |
* from to remove bytes from the buffer.
|
@@ -12,11 +11,10 @@ use Psr\Http\Message\StreamInterface;
|
|
12 |
* what the configured high water mark of the stream is, or the maximum
|
13 |
* preferred size of the buffer.
|
14 |
*/
|
15 |
-
class BufferStream implements StreamInterface
|
16 |
{
|
17 |
private $hwm;
|
18 |
private $buffer = '';
|
19 |
-
|
20 |
/**
|
21 |
* @param int $hwm High water mark, representing the preferred maximum
|
22 |
* buffer size. If the size of the buffer exceeds the high
|
@@ -28,113 +26,91 @@ class BufferStream implements StreamInterface
|
|
28 |
{
|
29 |
$this->hwm = $hwm;
|
30 |
}
|
31 |
-
|
32 |
public function __toString()
|
33 |
{
|
34 |
return $this->getContents();
|
35 |
}
|
36 |
-
|
37 |
public function getContents()
|
38 |
{
|
39 |
$buffer = $this->buffer;
|
40 |
$this->buffer = '';
|
41 |
-
|
42 |
return $buffer;
|
43 |
}
|
44 |
-
|
45 |
public function close()
|
46 |
{
|
47 |
$this->buffer = '';
|
48 |
}
|
49 |
-
|
50 |
public function detach()
|
51 |
{
|
52 |
$this->close();
|
53 |
-
|
54 |
return null;
|
55 |
}
|
56 |
-
|
57 |
public function getSize()
|
58 |
{
|
59 |
-
return strlen($this->buffer);
|
60 |
}
|
61 |
-
|
62 |
public function isReadable()
|
63 |
{
|
64 |
-
return true;
|
65 |
}
|
66 |
-
|
67 |
public function isWritable()
|
68 |
{
|
69 |
-
return true;
|
70 |
}
|
71 |
-
|
72 |
public function isSeekable()
|
73 |
{
|
74 |
-
return false;
|
75 |
}
|
76 |
-
|
77 |
public function rewind()
|
78 |
{
|
79 |
$this->seek(0);
|
80 |
}
|
81 |
-
|
82 |
-
public function seek($offset, $whence = SEEK_SET)
|
83 |
{
|
84 |
throw new \RuntimeException('Cannot seek a BufferStream');
|
85 |
}
|
86 |
-
|
87 |
public function eof()
|
88 |
{
|
89 |
-
return strlen($this->buffer) === 0;
|
90 |
}
|
91 |
-
|
92 |
public function tell()
|
93 |
{
|
94 |
throw new \RuntimeException('Cannot determine the position of a BufferStream');
|
95 |
}
|
96 |
-
|
97 |
/**
|
98 |
* Reads data from the buffer.
|
99 |
*/
|
100 |
public function read($length)
|
101 |
{
|
102 |
-
$currentLength = strlen($this->buffer);
|
103 |
-
|
104 |
if ($length >= $currentLength) {
|
105 |
// No need to slice the buffer because we don't have enough data.
|
106 |
$result = $this->buffer;
|
107 |
$this->buffer = '';
|
108 |
} else {
|
109 |
// Slice up the result to provide a subset of the buffer.
|
110 |
-
$result = substr($this->buffer, 0, $length);
|
111 |
-
$this->buffer = substr($this->buffer, $length);
|
112 |
}
|
113 |
-
|
114 |
return $result;
|
115 |
}
|
116 |
-
|
117 |
/**
|
118 |
* Writes data to the buffer.
|
119 |
*/
|
120 |
public function write($string)
|
121 |
{
|
122 |
$this->buffer .= $string;
|
123 |
-
|
124 |
// TODO: What should happen here?
|
125 |
-
if (strlen($this->buffer) >= $this->hwm) {
|
126 |
-
return false;
|
127 |
}
|
128 |
-
|
129 |
-
return strlen($string);
|
130 |
}
|
131 |
-
|
132 |
public function getMetadata($key = null)
|
133 |
{
|
134 |
if ($key == 'hwm') {
|
135 |
return $this->hwm;
|
136 |
}
|
137 |
-
|
138 |
return $key ? null : [];
|
139 |
}
|
140 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Provides a buffer stream that can be written to to fill a buffer, and read
|
8 |
* from to remove bytes from the buffer.
|
11 |
* what the configured high water mark of the stream is, or the maximum
|
12 |
* preferred size of the buffer.
|
13 |
*/
|
14 |
+
class BufferStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
15 |
{
|
16 |
private $hwm;
|
17 |
private $buffer = '';
|
|
|
18 |
/**
|
19 |
* @param int $hwm High water mark, representing the preferred maximum
|
20 |
* buffer size. If the size of the buffer exceeds the high
|
26 |
{
|
27 |
$this->hwm = $hwm;
|
28 |
}
|
|
|
29 |
public function __toString()
|
30 |
{
|
31 |
return $this->getContents();
|
32 |
}
|
|
|
33 |
public function getContents()
|
34 |
{
|
35 |
$buffer = $this->buffer;
|
36 |
$this->buffer = '';
|
|
|
37 |
return $buffer;
|
38 |
}
|
|
|
39 |
public function close()
|
40 |
{
|
41 |
$this->buffer = '';
|
42 |
}
|
|
|
43 |
public function detach()
|
44 |
{
|
45 |
$this->close();
|
|
|
46 |
return null;
|
47 |
}
|
|
|
48 |
public function getSize()
|
49 |
{
|
50 |
+
return \strlen($this->buffer);
|
51 |
}
|
|
|
52 |
public function isReadable()
|
53 |
{
|
54 |
+
return \true;
|
55 |
}
|
|
|
56 |
public function isWritable()
|
57 |
{
|
58 |
+
return \true;
|
59 |
}
|
|
|
60 |
public function isSeekable()
|
61 |
{
|
62 |
+
return \false;
|
63 |
}
|
|
|
64 |
public function rewind()
|
65 |
{
|
66 |
$this->seek(0);
|
67 |
}
|
68 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
69 |
{
|
70 |
throw new \RuntimeException('Cannot seek a BufferStream');
|
71 |
}
|
|
|
72 |
public function eof()
|
73 |
{
|
74 |
+
return \strlen($this->buffer) === 0;
|
75 |
}
|
|
|
76 |
public function tell()
|
77 |
{
|
78 |
throw new \RuntimeException('Cannot determine the position of a BufferStream');
|
79 |
}
|
|
|
80 |
/**
|
81 |
* Reads data from the buffer.
|
82 |
*/
|
83 |
public function read($length)
|
84 |
{
|
85 |
+
$currentLength = \strlen($this->buffer);
|
|
|
86 |
if ($length >= $currentLength) {
|
87 |
// No need to slice the buffer because we don't have enough data.
|
88 |
$result = $this->buffer;
|
89 |
$this->buffer = '';
|
90 |
} else {
|
91 |
// Slice up the result to provide a subset of the buffer.
|
92 |
+
$result = \substr($this->buffer, 0, $length);
|
93 |
+
$this->buffer = \substr($this->buffer, $length);
|
94 |
}
|
|
|
95 |
return $result;
|
96 |
}
|
|
|
97 |
/**
|
98 |
* Writes data to the buffer.
|
99 |
*/
|
100 |
public function write($string)
|
101 |
{
|
102 |
$this->buffer .= $string;
|
|
|
103 |
// TODO: What should happen here?
|
104 |
+
if (\strlen($this->buffer) >= $this->hwm) {
|
105 |
+
return \false;
|
106 |
}
|
107 |
+
return \strlen($string);
|
|
|
108 |
}
|
|
|
109 |
public function getMetadata($key = null)
|
110 |
{
|
111 |
if ($key == 'hwm') {
|
112 |
return $this->hwm;
|
113 |
}
|
|
|
114 |
return $key ? null : [];
|
115 |
}
|
116 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/CachingStream.php
RENAMED
@@ -1,54 +1,45 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Stream decorator that can cache previously read bytes from a sequentially
|
9 |
* read stream.
|
10 |
*/
|
11 |
-
class CachingStream implements StreamInterface
|
12 |
{
|
13 |
use StreamDecoratorTrait;
|
14 |
-
|
15 |
/** @var StreamInterface Stream being wrapped */
|
16 |
private $remoteStream;
|
17 |
-
|
18 |
/** @var int Number of bytes to skip reading due to a write on the buffer */
|
19 |
private $skipReadBytes = 0;
|
20 |
-
|
21 |
/**
|
22 |
* We will treat the buffer object as the body of the stream
|
23 |
*
|
24 |
* @param StreamInterface $stream Stream to cache
|
25 |
* @param StreamInterface $target Optionally specify where data is cached
|
26 |
*/
|
27 |
-
public function __construct(
|
28 |
-
|
29 |
-
StreamInterface $target = null
|
30 |
-
) {
|
31 |
$this->remoteStream = $stream;
|
32 |
-
$this->stream = $target ?: new Stream(fopen('php://temp', 'r+'));
|
33 |
}
|
34 |
-
|
35 |
public function getSize()
|
36 |
{
|
37 |
-
return max($this->stream->getSize(), $this->remoteStream->getSize());
|
38 |
}
|
39 |
-
|
40 |
public function rewind()
|
41 |
{
|
42 |
$this->seek(0);
|
43 |
}
|
44 |
-
|
45 |
-
public function seek($offset, $whence = SEEK_SET)
|
46 |
{
|
47 |
-
if ($whence == SEEK_SET) {
|
48 |
$byte = $offset;
|
49 |
-
} elseif ($whence == SEEK_CUR) {
|
50 |
$byte = $offset + $this->tell();
|
51 |
-
} elseif ($whence == SEEK_END) {
|
52 |
$size = $this->remoteStream->getSize();
|
53 |
if ($size === null) {
|
54 |
$size = $this->cacheEntireStream();
|
@@ -57,9 +48,7 @@ class CachingStream implements StreamInterface
|
|
57 |
} else {
|
58 |
throw new \InvalidArgumentException('Invalid whence');
|
59 |
}
|
60 |
-
|
61 |
$diff = $byte - $this->stream->getSize();
|
62 |
-
|
63 |
if ($diff > 0) {
|
64 |
// Read the remoteStream until we have read in at least the amount
|
65 |
// of bytes requested, or we reach the end of the file.
|
@@ -72,55 +61,44 @@ class CachingStream implements StreamInterface
|
|
72 |
$this->stream->seek($byte);
|
73 |
}
|
74 |
}
|
75 |
-
|
76 |
public function read($length)
|
77 |
{
|
78 |
// Perform a regular read on any previously read data from the buffer
|
79 |
$data = $this->stream->read($length);
|
80 |
-
$remaining = $length - strlen($data);
|
81 |
-
|
82 |
// More data was requested so read from the remote stream
|
83 |
if ($remaining) {
|
84 |
// If data was written to the buffer in a position that would have
|
85 |
// been filled from the remote stream, then we must skip bytes on
|
86 |
// the remote stream to emulate overwriting bytes from that
|
87 |
// position. This mimics the behavior of other PHP stream wrappers.
|
88 |
-
$remoteData = $this->remoteStream->read(
|
89 |
-
$remaining + $this->skipReadBytes
|
90 |
-
);
|
91 |
-
|
92 |
if ($this->skipReadBytes) {
|
93 |
-
$len = strlen($remoteData);
|
94 |
-
$remoteData = substr($remoteData, $this->skipReadBytes);
|
95 |
-
$this->skipReadBytes = max(0, $this->skipReadBytes - $len);
|
96 |
}
|
97 |
-
|
98 |
$data .= $remoteData;
|
99 |
$this->stream->write($remoteData);
|
100 |
}
|
101 |
-
|
102 |
return $data;
|
103 |
}
|
104 |
-
|
105 |
public function write($string)
|
106 |
{
|
107 |
// When appending to the end of the currently read stream, you'll want
|
108 |
// to skip bytes from being read from the remote stream to emulate
|
109 |
// other stream wrappers. Basically replacing bytes of data of a fixed
|
110 |
// length.
|
111 |
-
$overflow =
|
112 |
if ($overflow > 0) {
|
113 |
$this->skipReadBytes += $overflow;
|
114 |
}
|
115 |
-
|
116 |
return $this->stream->write($string);
|
117 |
}
|
118 |
-
|
119 |
public function eof()
|
120 |
{
|
121 |
return $this->stream->eof() && $this->remoteStream->eof();
|
122 |
}
|
123 |
-
|
124 |
/**
|
125 |
* Close both the remote stream and buffer stream
|
126 |
*/
|
@@ -128,12 +106,10 @@ class CachingStream implements StreamInterface
|
|
128 |
{
|
129 |
$this->remoteStream->close() && $this->stream->close();
|
130 |
}
|
131 |
-
|
132 |
private function cacheEntireStream()
|
133 |
{
|
134 |
-
$target = new FnStream(['write' => 'strlen']);
|
135 |
-
Utils::copyToStream($this, $target);
|
136 |
-
|
137 |
return $this->tell();
|
138 |
}
|
139 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Stream decorator that can cache previously read bytes from a sequentially
|
8 |
* read stream.
|
9 |
*/
|
10 |
+
class CachingStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
11 |
{
|
12 |
use StreamDecoratorTrait;
|
|
|
13 |
/** @var StreamInterface Stream being wrapped */
|
14 |
private $remoteStream;
|
|
|
15 |
/** @var int Number of bytes to skip reading due to a write on the buffer */
|
16 |
private $skipReadBytes = 0;
|
|
|
17 |
/**
|
18 |
* We will treat the buffer object as the body of the stream
|
19 |
*
|
20 |
* @param StreamInterface $stream Stream to cache
|
21 |
* @param StreamInterface $target Optionally specify where data is cached
|
22 |
*/
|
23 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $target = null)
|
24 |
+
{
|
|
|
|
|
25 |
$this->remoteStream = $stream;
|
26 |
+
$this->stream = $target ?: new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Stream(\fopen('php://temp', 'r+'));
|
27 |
}
|
|
|
28 |
public function getSize()
|
29 |
{
|
30 |
+
return \max($this->stream->getSize(), $this->remoteStream->getSize());
|
31 |
}
|
|
|
32 |
public function rewind()
|
33 |
{
|
34 |
$this->seek(0);
|
35 |
}
|
36 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
37 |
{
|
38 |
+
if ($whence == \SEEK_SET) {
|
39 |
$byte = $offset;
|
40 |
+
} elseif ($whence == \SEEK_CUR) {
|
41 |
$byte = $offset + $this->tell();
|
42 |
+
} elseif ($whence == \SEEK_END) {
|
43 |
$size = $this->remoteStream->getSize();
|
44 |
if ($size === null) {
|
45 |
$size = $this->cacheEntireStream();
|
48 |
} else {
|
49 |
throw new \InvalidArgumentException('Invalid whence');
|
50 |
}
|
|
|
51 |
$diff = $byte - $this->stream->getSize();
|
|
|
52 |
if ($diff > 0) {
|
53 |
// Read the remoteStream until we have read in at least the amount
|
54 |
// of bytes requested, or we reach the end of the file.
|
61 |
$this->stream->seek($byte);
|
62 |
}
|
63 |
}
|
|
|
64 |
public function read($length)
|
65 |
{
|
66 |
// Perform a regular read on any previously read data from the buffer
|
67 |
$data = $this->stream->read($length);
|
68 |
+
$remaining = $length - \strlen($data);
|
|
|
69 |
// More data was requested so read from the remote stream
|
70 |
if ($remaining) {
|
71 |
// If data was written to the buffer in a position that would have
|
72 |
// been filled from the remote stream, then we must skip bytes on
|
73 |
// the remote stream to emulate overwriting bytes from that
|
74 |
// position. This mimics the behavior of other PHP stream wrappers.
|
75 |
+
$remoteData = $this->remoteStream->read($remaining + $this->skipReadBytes);
|
|
|
|
|
|
|
76 |
if ($this->skipReadBytes) {
|
77 |
+
$len = \strlen($remoteData);
|
78 |
+
$remoteData = \substr($remoteData, $this->skipReadBytes);
|
79 |
+
$this->skipReadBytes = \max(0, $this->skipReadBytes - $len);
|
80 |
}
|
|
|
81 |
$data .= $remoteData;
|
82 |
$this->stream->write($remoteData);
|
83 |
}
|
|
|
84 |
return $data;
|
85 |
}
|
|
|
86 |
public function write($string)
|
87 |
{
|
88 |
// When appending to the end of the currently read stream, you'll want
|
89 |
// to skip bytes from being read from the remote stream to emulate
|
90 |
// other stream wrappers. Basically replacing bytes of data of a fixed
|
91 |
// length.
|
92 |
+
$overflow = \strlen($string) + $this->tell() - $this->remoteStream->tell();
|
93 |
if ($overflow > 0) {
|
94 |
$this->skipReadBytes += $overflow;
|
95 |
}
|
|
|
96 |
return $this->stream->write($string);
|
97 |
}
|
|
|
98 |
public function eof()
|
99 |
{
|
100 |
return $this->stream->eof() && $this->remoteStream->eof();
|
101 |
}
|
|
|
102 |
/**
|
103 |
* Close both the remote stream and buffer stream
|
104 |
*/
|
106 |
{
|
107 |
$this->remoteStream->close() && $this->stream->close();
|
108 |
}
|
|
|
109 |
private function cacheEntireStream()
|
110 |
{
|
111 |
+
$target = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\FnStream(['write' => 'strlen']);
|
112 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::copyToStream($this, $target);
|
|
|
113 |
return $this->tell();
|
114 |
}
|
115 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/DroppingStream.php
RENAMED
@@ -1,43 +1,36 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Stream decorator that begins dropping data once the size of the underlying
|
9 |
* stream becomes too full.
|
10 |
*/
|
11 |
-
class DroppingStream implements StreamInterface
|
12 |
{
|
13 |
use StreamDecoratorTrait;
|
14 |
-
|
15 |
private $maxLength;
|
16 |
-
|
17 |
/**
|
18 |
* @param StreamInterface $stream Underlying stream to decorate.
|
19 |
* @param int $maxLength Maximum size before dropping data.
|
20 |
*/
|
21 |
-
public function __construct(StreamInterface $stream, $maxLength)
|
22 |
{
|
23 |
$this->stream = $stream;
|
24 |
$this->maxLength = $maxLength;
|
25 |
}
|
26 |
-
|
27 |
public function write($string)
|
28 |
{
|
29 |
$diff = $this->maxLength - $this->stream->getSize();
|
30 |
-
|
31 |
// Begin returning 0 when the underlying stream is too large.
|
32 |
if ($diff <= 0) {
|
33 |
return 0;
|
34 |
}
|
35 |
-
|
36 |
// Write the stream or a subset of the stream if needed.
|
37 |
-
if (strlen($string) < $diff) {
|
38 |
return $this->stream->write($string);
|
39 |
}
|
40 |
-
|
41 |
-
return $this->stream->write(substr($string, 0, $diff));
|
42 |
}
|
43 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Stream decorator that begins dropping data once the size of the underlying
|
8 |
* stream becomes too full.
|
9 |
*/
|
10 |
+
class DroppingStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
11 |
{
|
12 |
use StreamDecoratorTrait;
|
|
|
13 |
private $maxLength;
|
|
|
14 |
/**
|
15 |
* @param StreamInterface $stream Underlying stream to decorate.
|
16 |
* @param int $maxLength Maximum size before dropping data.
|
17 |
*/
|
18 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, $maxLength)
|
19 |
{
|
20 |
$this->stream = $stream;
|
21 |
$this->maxLength = $maxLength;
|
22 |
}
|
|
|
23 |
public function write($string)
|
24 |
{
|
25 |
$diff = $this->maxLength - $this->stream->getSize();
|
|
|
26 |
// Begin returning 0 when the underlying stream is too large.
|
27 |
if ($diff <= 0) {
|
28 |
return 0;
|
29 |
}
|
|
|
30 |
// Write the stream or a subset of the stream if needed.
|
31 |
+
if (\strlen($string) < $diff) {
|
32 |
return $this->stream->write($string);
|
33 |
}
|
34 |
+
return $this->stream->write(\substr($string, 0, $diff));
|
|
|
35 |
}
|
36 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/FnStream.php
RENAMED
@@ -1,38 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Compose stream implementations based on a hash of functions.
|
9 |
*
|
10 |
* Allows for easy testing and extension of a provided stream without needing
|
11 |
* to create a concrete class for a simple extension point.
|
12 |
*/
|
13 |
-
class FnStream implements StreamInterface
|
14 |
{
|
15 |
/** @var array */
|
16 |
private $methods;
|
17 |
-
|
18 |
/** @var array Methods that must be implemented in the given array */
|
19 |
-
private static $slots = ['__toString', 'close', 'detach', 'rewind',
|
20 |
-
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
|
21 |
-
'isReadable', 'read', 'getContents', 'getMetadata'];
|
22 |
-
|
23 |
/**
|
24 |
* @param array $methods Hash of method name to a callable.
|
25 |
*/
|
26 |
public function __construct(array $methods)
|
27 |
{
|
28 |
$this->methods = $methods;
|
29 |
-
|
30 |
// Create the functions on the class
|
31 |
foreach ($methods as $name => $fn) {
|
32 |
$this->{'_fn_' . $name} = $fn;
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
/**
|
37 |
* Lazily determine which methods are not implemented.
|
38 |
*
|
@@ -40,20 +33,17 @@ class FnStream implements StreamInterface
|
|
40 |
*/
|
41 |
public function __get($name)
|
42 |
{
|
43 |
-
throw new \BadMethodCallException(str_replace('_fn_', '', $name)
|
44 |
-
. '() is not implemented in the FnStream');
|
45 |
}
|
46 |
-
|
47 |
/**
|
48 |
* The close method is called on the underlying stream only if possible.
|
49 |
*/
|
50 |
public function __destruct()
|
51 |
{
|
52 |
if (isset($this->_fn_close)) {
|
53 |
-
call_user_func($this->_fn_close);
|
54 |
}
|
55 |
}
|
56 |
-
|
57 |
/**
|
58 |
* An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
|
59 |
* @throws \LogicException
|
@@ -62,7 +52,6 @@ class FnStream implements StreamInterface
|
|
62 |
{
|
63 |
throw new \LogicException('FnStream should never be unserialized');
|
64 |
}
|
65 |
-
|
66 |
/**
|
67 |
* Adds custom functionality to an underlying stream by intercepting
|
68 |
* specific method calls.
|
@@ -72,89 +61,73 @@ class FnStream implements StreamInterface
|
|
72 |
*
|
73 |
* @return FnStream
|
74 |
*/
|
75 |
-
public static function decorate(StreamInterface $stream, array $methods)
|
76 |
{
|
77 |
// If any of the required methods were not provided, then simply
|
78 |
// proxy to the decorated stream.
|
79 |
-
foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
|
80 |
$methods[$diff] = [$stream, $diff];
|
81 |
}
|
82 |
-
|
83 |
return new self($methods);
|
84 |
}
|
85 |
-
|
86 |
public function __toString()
|
87 |
{
|
88 |
-
return call_user_func($this->_fn___toString);
|
89 |
}
|
90 |
-
|
91 |
public function close()
|
92 |
{
|
93 |
-
return call_user_func($this->_fn_close);
|
94 |
}
|
95 |
-
|
96 |
public function detach()
|
97 |
{
|
98 |
-
return call_user_func($this->_fn_detach);
|
99 |
}
|
100 |
-
|
101 |
public function getSize()
|
102 |
{
|
103 |
-
return call_user_func($this->_fn_getSize);
|
104 |
}
|
105 |
-
|
106 |
public function tell()
|
107 |
{
|
108 |
-
return call_user_func($this->_fn_tell);
|
109 |
}
|
110 |
-
|
111 |
public function eof()
|
112 |
{
|
113 |
-
return call_user_func($this->_fn_eof);
|
114 |
}
|
115 |
-
|
116 |
public function isSeekable()
|
117 |
{
|
118 |
-
return call_user_func($this->_fn_isSeekable);
|
119 |
}
|
120 |
-
|
121 |
public function rewind()
|
122 |
{
|
123 |
-
call_user_func($this->_fn_rewind);
|
124 |
}
|
125 |
-
|
126 |
-
public function seek($offset, $whence = SEEK_SET)
|
127 |
{
|
128 |
-
call_user_func($this->_fn_seek, $offset, $whence);
|
129 |
}
|
130 |
-
|
131 |
public function isWritable()
|
132 |
{
|
133 |
-
return call_user_func($this->_fn_isWritable);
|
134 |
}
|
135 |
-
|
136 |
public function write($string)
|
137 |
{
|
138 |
-
return call_user_func($this->_fn_write, $string);
|
139 |
}
|
140 |
-
|
141 |
public function isReadable()
|
142 |
{
|
143 |
-
return call_user_func($this->_fn_isReadable);
|
144 |
}
|
145 |
-
|
146 |
public function read($length)
|
147 |
{
|
148 |
-
return call_user_func($this->_fn_read, $length);
|
149 |
}
|
150 |
-
|
151 |
public function getContents()
|
152 |
{
|
153 |
-
return call_user_func($this->_fn_getContents);
|
154 |
}
|
155 |
-
|
156 |
public function getMetadata($key = null)
|
157 |
{
|
158 |
-
return call_user_func($this->_fn_getMetadata, $key);
|
159 |
}
|
160 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Compose stream implementations based on a hash of functions.
|
8 |
*
|
9 |
* Allows for easy testing and extension of a provided stream without needing
|
10 |
* to create a concrete class for a simple extension point.
|
11 |
*/
|
12 |
+
class FnStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
13 |
{
|
14 |
/** @var array */
|
15 |
private $methods;
|
|
|
16 |
/** @var array Methods that must be implemented in the given array */
|
17 |
+
private static $slots = ['__toString', 'close', 'detach', 'rewind', 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', 'isReadable', 'read', 'getContents', 'getMetadata'];
|
|
|
|
|
|
|
18 |
/**
|
19 |
* @param array $methods Hash of method name to a callable.
|
20 |
*/
|
21 |
public function __construct(array $methods)
|
22 |
{
|
23 |
$this->methods = $methods;
|
|
|
24 |
// Create the functions on the class
|
25 |
foreach ($methods as $name => $fn) {
|
26 |
$this->{'_fn_' . $name} = $fn;
|
27 |
}
|
28 |
}
|
|
|
29 |
/**
|
30 |
* Lazily determine which methods are not implemented.
|
31 |
*
|
33 |
*/
|
34 |
public function __get($name)
|
35 |
{
|
36 |
+
throw new \BadMethodCallException(\str_replace('_fn_', '', $name) . '() is not implemented in the FnStream');
|
|
|
37 |
}
|
|
|
38 |
/**
|
39 |
* The close method is called on the underlying stream only if possible.
|
40 |
*/
|
41 |
public function __destruct()
|
42 |
{
|
43 |
if (isset($this->_fn_close)) {
|
44 |
+
\call_user_func($this->_fn_close);
|
45 |
}
|
46 |
}
|
|
|
47 |
/**
|
48 |
* An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
|
49 |
* @throws \LogicException
|
52 |
{
|
53 |
throw new \LogicException('FnStream should never be unserialized');
|
54 |
}
|
|
|
55 |
/**
|
56 |
* Adds custom functionality to an underlying stream by intercepting
|
57 |
* specific method calls.
|
61 |
*
|
62 |
* @return FnStream
|
63 |
*/
|
64 |
+
public static function decorate(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, array $methods)
|
65 |
{
|
66 |
// If any of the required methods were not provided, then simply
|
67 |
// proxy to the decorated stream.
|
68 |
+
foreach (\array_diff(self::$slots, \array_keys($methods)) as $diff) {
|
69 |
$methods[$diff] = [$stream, $diff];
|
70 |
}
|
|
|
71 |
return new self($methods);
|
72 |
}
|
|
|
73 |
public function __toString()
|
74 |
{
|
75 |
+
return \call_user_func($this->_fn___toString);
|
76 |
}
|
|
|
77 |
public function close()
|
78 |
{
|
79 |
+
return \call_user_func($this->_fn_close);
|
80 |
}
|
|
|
81 |
public function detach()
|
82 |
{
|
83 |
+
return \call_user_func($this->_fn_detach);
|
84 |
}
|
|
|
85 |
public function getSize()
|
86 |
{
|
87 |
+
return \call_user_func($this->_fn_getSize);
|
88 |
}
|
|
|
89 |
public function tell()
|
90 |
{
|
91 |
+
return \call_user_func($this->_fn_tell);
|
92 |
}
|
|
|
93 |
public function eof()
|
94 |
{
|
95 |
+
return \call_user_func($this->_fn_eof);
|
96 |
}
|
|
|
97 |
public function isSeekable()
|
98 |
{
|
99 |
+
return \call_user_func($this->_fn_isSeekable);
|
100 |
}
|
|
|
101 |
public function rewind()
|
102 |
{
|
103 |
+
\call_user_func($this->_fn_rewind);
|
104 |
}
|
105 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
106 |
{
|
107 |
+
\call_user_func($this->_fn_seek, $offset, $whence);
|
108 |
}
|
|
|
109 |
public function isWritable()
|
110 |
{
|
111 |
+
return \call_user_func($this->_fn_isWritable);
|
112 |
}
|
|
|
113 |
public function write($string)
|
114 |
{
|
115 |
+
return \call_user_func($this->_fn_write, $string);
|
116 |
}
|
|
|
117 |
public function isReadable()
|
118 |
{
|
119 |
+
return \call_user_func($this->_fn_isReadable);
|
120 |
}
|
|
|
121 |
public function read($length)
|
122 |
{
|
123 |
+
return \call_user_func($this->_fn_read, $length);
|
124 |
}
|
|
|
125 |
public function getContents()
|
126 |
{
|
127 |
+
return \call_user_func($this->_fn_getContents);
|
128 |
}
|
|
|
129 |
public function getMetadata($key = null)
|
130 |
{
|
131 |
+
return \call_user_func($this->_fn_getMetadata, $key);
|
132 |
}
|
133 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Header.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Header
|
6 |
{
|
@@ -18,16 +18,15 @@ final class Header
|
|
18 |
{
|
19 |
static $trimmed = "\"' \n\t\r";
|
20 |
$params = $matches = [];
|
21 |
-
|
22 |
foreach (self::normalize($header) as $val) {
|
23 |
$part = [];
|
24 |
-
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
|
25 |
-
if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
26 |
$m = $matches[0];
|
27 |
if (isset($m[1])) {
|
28 |
-
$part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
|
29 |
} else {
|
30 |
-
$part[] = trim($m[0], $trimmed);
|
31 |
}
|
32 |
}
|
33 |
}
|
@@ -35,10 +34,8 @@ final class Header
|
|
35 |
$params[] = $part;
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
return $params;
|
40 |
}
|
41 |
-
|
42 |
/**
|
43 |
* Converts an array of header values that may contain comma separated
|
44 |
* headers into an array of headers with no comma separated values.
|
@@ -49,23 +46,21 @@ final class Header
|
|
49 |
*/
|
50 |
public static function normalize($header)
|
51 |
{
|
52 |
-
if (
|
53 |
-
return array_map('trim', explode(',', $header));
|
54 |
}
|
55 |
-
|
56 |
$result = [];
|
57 |
foreach ($header as $value) {
|
58 |
foreach ((array) $value as $v) {
|
59 |
-
if (strpos($v, ',') === false) {
|
60 |
$result[] = $v;
|
61 |
continue;
|
62 |
}
|
63 |
-
foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
|
64 |
-
$result[] = trim($vv);
|
65 |
}
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
return $result;
|
70 |
}
|
71 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Header
|
6 |
{
|
18 |
{
|
19 |
static $trimmed = "\"' \n\t\r";
|
20 |
$params = $matches = [];
|
|
|
21 |
foreach (self::normalize($header) as $val) {
|
22 |
$part = [];
|
23 |
+
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
|
24 |
+
if (\preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
25 |
$m = $matches[0];
|
26 |
if (isset($m[1])) {
|
27 |
+
$part[\trim($m[0], $trimmed)] = \trim($m[1], $trimmed);
|
28 |
} else {
|
29 |
+
$part[] = \trim($m[0], $trimmed);
|
30 |
}
|
31 |
}
|
32 |
}
|
34 |
$params[] = $part;
|
35 |
}
|
36 |
}
|
|
|
37 |
return $params;
|
38 |
}
|
|
|
39 |
/**
|
40 |
* Converts an array of header values that may contain comma separated
|
41 |
* headers into an array of headers with no comma separated values.
|
46 |
*/
|
47 |
public static function normalize($header)
|
48 |
{
|
49 |
+
if (!\is_array($header)) {
|
50 |
+
return \array_map('trim', \explode(',', $header));
|
51 |
}
|
|
|
52 |
$result = [];
|
53 |
foreach ($header as $value) {
|
54 |
foreach ((array) $value as $v) {
|
55 |
+
if (\strpos($v, ',') === \false) {
|
56 |
$result[] = $v;
|
57 |
continue;
|
58 |
}
|
59 |
+
foreach (\preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
|
60 |
+
$result[] = \trim($vv);
|
61 |
}
|
62 |
}
|
63 |
}
|
|
|
64 |
return $result;
|
65 |
}
|
66 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/InflateStream.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
9 |
*
|
@@ -15,39 +14,35 @@ use Psr\Http\Message\StreamInterface;
|
|
15 |
* @link http://tools.ietf.org/html/rfc1952
|
16 |
* @link http://php.net/manual/en/filters.compression.php
|
17 |
*/
|
18 |
-
class InflateStream implements StreamInterface
|
19 |
{
|
20 |
use StreamDecoratorTrait;
|
21 |
-
|
22 |
-
public function __construct(StreamInterface $stream)
|
23 |
{
|
24 |
// read the first 10 bytes, ie. gzip header
|
25 |
$header = $stream->read(10);
|
26 |
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
|
27 |
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
|
28 |
-
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
|
29 |
-
$resource = StreamWrapper::getResource($stream);
|
30 |
-
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
|
31 |
-
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
|
32 |
}
|
33 |
-
|
34 |
/**
|
35 |
* @param StreamInterface $stream
|
36 |
* @param $header
|
37 |
* @return int
|
38 |
*/
|
39 |
-
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
|
40 |
{
|
41 |
$filename_header_length = 0;
|
42 |
-
|
43 |
-
if (substr(bin2hex($header), 6, 2) === '08') {
|
44 |
// we have a filename, read until nil
|
45 |
$filename_header_length = 1;
|
46 |
-
while ($stream->read(1) !== chr(0)) {
|
47 |
$filename_header_length++;
|
48 |
}
|
49 |
}
|
50 |
-
|
51 |
return $filename_header_length;
|
52 |
}
|
53 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
8 |
*
|
14 |
* @link http://tools.ietf.org/html/rfc1952
|
15 |
* @link http://php.net/manual/en/filters.compression.php
|
16 |
*/
|
17 |
+
class InflateStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
18 |
{
|
19 |
use StreamDecoratorTrait;
|
20 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream)
|
|
|
21 |
{
|
22 |
// read the first 10 bytes, ie. gzip header
|
23 |
$header = $stream->read(10);
|
24 |
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
|
25 |
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
|
26 |
+
$stream = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LimitStream($stream, -1, 10 + $filenameHeaderLength);
|
27 |
+
$resource = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\StreamWrapper::getResource($stream);
|
28 |
+
\stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ);
|
29 |
+
$this->stream = $stream->isSeekable() ? new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Stream($resource) : new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\NoSeekStream(new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Stream($resource));
|
30 |
}
|
|
|
31 |
/**
|
32 |
* @param StreamInterface $stream
|
33 |
* @param $header
|
34 |
* @return int
|
35 |
*/
|
36 |
+
private function getLengthOfPossibleFilenameHeader(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, $header)
|
37 |
{
|
38 |
$filename_header_length = 0;
|
39 |
+
if (\substr(\bin2hex($header), 6, 2) === '08') {
|
|
|
40 |
// we have a filename, read until nil
|
41 |
$filename_header_length = 1;
|
42 |
+
while ($stream->read(1) !== \chr(0)) {
|
43 |
$filename_header_length++;
|
44 |
}
|
45 |
}
|
|
|
46 |
return $filename_header_length;
|
47 |
}
|
48 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/LazyOpenStream.php
RENAMED
@@ -1,23 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Lazily reads or writes to a file that is opened only after an IO operation
|
9 |
* take place on the stream.
|
10 |
*/
|
11 |
-
class LazyOpenStream implements StreamInterface
|
12 |
{
|
13 |
use StreamDecoratorTrait;
|
14 |
-
|
15 |
/** @var string File to open */
|
16 |
private $filename;
|
17 |
-
|
18 |
/** @var string $mode */
|
19 |
private $mode;
|
20 |
-
|
21 |
/**
|
22 |
* @param string $filename File to lazily open
|
23 |
* @param string $mode fopen mode to use when opening the stream
|
@@ -27,7 +23,6 @@ class LazyOpenStream implements StreamInterface
|
|
27 |
$this->filename = $filename;
|
28 |
$this->mode = $mode;
|
29 |
}
|
30 |
-
|
31 |
/**
|
32 |
* Creates the underlying stream lazily when required.
|
33 |
*
|
@@ -35,6 +30,6 @@ class LazyOpenStream implements StreamInterface
|
|
35 |
*/
|
36 |
protected function createStream()
|
37 |
{
|
38 |
-
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
|
39 |
}
|
40 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Lazily reads or writes to a file that is opened only after an IO operation
|
8 |
* take place on the stream.
|
9 |
*/
|
10 |
+
class LazyOpenStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
11 |
{
|
12 |
use StreamDecoratorTrait;
|
|
|
13 |
/** @var string File to open */
|
14 |
private $filename;
|
|
|
15 |
/** @var string $mode */
|
16 |
private $mode;
|
|
|
17 |
/**
|
18 |
* @param string $filename File to lazily open
|
19 |
* @param string $mode fopen mode to use when opening the stream
|
23 |
$this->filename = $filename;
|
24 |
$this->mode = $mode;
|
25 |
}
|
|
|
26 |
/**
|
27 |
* Creates the underlying stream lazily when required.
|
28 |
*
|
30 |
*/
|
31 |
protected function createStream()
|
32 |
{
|
33 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::tryFopen($this->filename, $this->mode));
|
34 |
}
|
35 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/LimitStream.php
RENAMED
@@ -1,23 +1,18 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
-
|
7 |
|
|
|
8 |
/**
|
9 |
* Decorator used to return only a subset of a stream
|
10 |
*/
|
11 |
-
class LimitStream implements StreamInterface
|
12 |
{
|
13 |
use StreamDecoratorTrait;
|
14 |
-
|
15 |
/** @var int Offset to start reading from */
|
16 |
private $offset;
|
17 |
-
|
18 |
/** @var int Limit the number of bytes that can be read */
|
19 |
private $limit;
|
20 |
-
|
21 |
/**
|
22 |
* @param StreamInterface $stream Stream to wrap
|
23 |
* @param int $limit Total number of bytes to allow to be read
|
@@ -25,31 +20,24 @@ class LimitStream implements StreamInterface
|
|
25 |
* @param int $offset Position to seek to before reading (only
|
26 |
* works on seekable streams).
|
27 |
*/
|
28 |
-
public function __construct(
|
29 |
-
|
30 |
-
$limit = -1,
|
31 |
-
$offset = 0
|
32 |
-
) {
|
33 |
$this->stream = $stream;
|
34 |
$this->setLimit($limit);
|
35 |
$this->setOffset($offset);
|
36 |
}
|
37 |
-
|
38 |
public function eof()
|
39 |
{
|
40 |
// Always return true if the underlying stream is EOF
|
41 |
if ($this->stream->eof()) {
|
42 |
-
return true;
|
43 |
}
|
44 |
-
|
45 |
// No limit and the underlying stream is not at EOF
|
46 |
if ($this->limit == -1) {
|
47 |
-
return false;
|
48 |
}
|
49 |
-
|
50 |
return $this->stream->tell() >= $this->offset + $this->limit;
|
51 |
}
|
52 |
-
|
53 |
/**
|
54 |
* Returns the size of the limited subset of data
|
55 |
* {@inheritdoc}
|
@@ -61,35 +49,26 @@ class LimitStream implements StreamInterface
|
|
61 |
} elseif ($this->limit == -1) {
|
62 |
return $length - $this->offset;
|
63 |
} else {
|
64 |
-
return min($this->limit, $length - $this->offset);
|
65 |
}
|
66 |
}
|
67 |
-
|
68 |
/**
|
69 |
* Allow for a bounded seek on the read limited stream
|
70 |
* {@inheritdoc}
|
71 |
*/
|
72 |
-
public function seek($offset, $whence = SEEK_SET)
|
73 |
{
|
74 |
-
if ($whence !== SEEK_SET || $offset < 0) {
|
75 |
-
throw new \RuntimeException(sprintf(
|
76 |
-
'Cannot seek to offset %s with whence %s',
|
77 |
-
$offset,
|
78 |
-
$whence
|
79 |
-
));
|
80 |
}
|
81 |
-
|
82 |
$offset += $this->offset;
|
83 |
-
|
84 |
if ($this->limit !== -1) {
|
85 |
if ($offset > $this->offset + $this->limit) {
|
86 |
$offset = $this->offset + $this->limit;
|
87 |
}
|
88 |
}
|
89 |
-
|
90 |
$this->stream->seek($offset);
|
91 |
}
|
92 |
-
|
93 |
/**
|
94 |
* Give a relative tell()
|
95 |
* {@inheritdoc}
|
@@ -98,7 +77,6 @@ class LimitStream implements StreamInterface
|
|
98 |
{
|
99 |
return $this->stream->tell() - $this->offset;
|
100 |
}
|
101 |
-
|
102 |
/**
|
103 |
* Set the offset to start limiting from
|
104 |
*
|
@@ -109,21 +87,18 @@ class LimitStream implements StreamInterface
|
|
109 |
public function setOffset($offset)
|
110 |
{
|
111 |
$current = $this->stream->tell();
|
112 |
-
|
113 |
if ($current !== $offset) {
|
114 |
// If the stream cannot seek to the offset position, then read to it
|
115 |
if ($this->stream->isSeekable()) {
|
116 |
$this->stream->seek($offset);
|
117 |
} elseif ($current > $offset) {
|
118 |
-
throw new \RuntimeException("Could not seek to stream offset $offset");
|
119 |
} else {
|
120 |
$this->stream->read($offset - $current);
|
121 |
}
|
122 |
}
|
123 |
-
|
124 |
$this->offset = $offset;
|
125 |
}
|
126 |
-
|
127 |
/**
|
128 |
* Set the limit of bytes that the decorator allows to be read from the
|
129 |
* stream.
|
@@ -135,22 +110,19 @@ class LimitStream implements StreamInterface
|
|
135 |
{
|
136 |
$this->limit = $limit;
|
137 |
}
|
138 |
-
|
139 |
public function read($length)
|
140 |
{
|
141 |
if ($this->limit == -1) {
|
142 |
return $this->stream->read($length);
|
143 |
}
|
144 |
-
|
145 |
// Check if the current position is less than the total allowed
|
146 |
// bytes + original offset
|
147 |
-
$remaining =
|
148 |
if ($remaining > 0) {
|
149 |
// Only return the amount of requested data, ensuring that the byte
|
150 |
// limit is not exceeded
|
151 |
-
return $this->stream->read(min($remaining, $length));
|
152 |
}
|
153 |
-
|
154 |
return '';
|
155 |
}
|
156 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Decorator used to return only a subset of a stream
|
8 |
*/
|
9 |
+
class LimitStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
10 |
{
|
11 |
use StreamDecoratorTrait;
|
|
|
12 |
/** @var int Offset to start reading from */
|
13 |
private $offset;
|
|
|
14 |
/** @var int Limit the number of bytes that can be read */
|
15 |
private $limit;
|
|
|
16 |
/**
|
17 |
* @param StreamInterface $stream Stream to wrap
|
18 |
* @param int $limit Total number of bytes to allow to be read
|
20 |
* @param int $offset Position to seek to before reading (only
|
21 |
* works on seekable streams).
|
22 |
*/
|
23 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, $limit = -1, $offset = 0)
|
24 |
+
{
|
|
|
|
|
|
|
25 |
$this->stream = $stream;
|
26 |
$this->setLimit($limit);
|
27 |
$this->setOffset($offset);
|
28 |
}
|
|
|
29 |
public function eof()
|
30 |
{
|
31 |
// Always return true if the underlying stream is EOF
|
32 |
if ($this->stream->eof()) {
|
33 |
+
return \true;
|
34 |
}
|
|
|
35 |
// No limit and the underlying stream is not at EOF
|
36 |
if ($this->limit == -1) {
|
37 |
+
return \false;
|
38 |
}
|
|
|
39 |
return $this->stream->tell() >= $this->offset + $this->limit;
|
40 |
}
|
|
|
41 |
/**
|
42 |
* Returns the size of the limited subset of data
|
43 |
* {@inheritdoc}
|
49 |
} elseif ($this->limit == -1) {
|
50 |
return $length - $this->offset;
|
51 |
} else {
|
52 |
+
return \min($this->limit, $length - $this->offset);
|
53 |
}
|
54 |
}
|
|
|
55 |
/**
|
56 |
* Allow for a bounded seek on the read limited stream
|
57 |
* {@inheritdoc}
|
58 |
*/
|
59 |
+
public function seek($offset, $whence = \SEEK_SET)
|
60 |
{
|
61 |
+
if ($whence !== \SEEK_SET || $offset < 0) {
|
62 |
+
throw new \RuntimeException(\sprintf('Cannot seek to offset %s with whence %s', $offset, $whence));
|
|
|
|
|
|
|
|
|
63 |
}
|
|
|
64 |
$offset += $this->offset;
|
|
|
65 |
if ($this->limit !== -1) {
|
66 |
if ($offset > $this->offset + $this->limit) {
|
67 |
$offset = $this->offset + $this->limit;
|
68 |
}
|
69 |
}
|
|
|
70 |
$this->stream->seek($offset);
|
71 |
}
|
|
|
72 |
/**
|
73 |
* Give a relative tell()
|
74 |
* {@inheritdoc}
|
77 |
{
|
78 |
return $this->stream->tell() - $this->offset;
|
79 |
}
|
|
|
80 |
/**
|
81 |
* Set the offset to start limiting from
|
82 |
*
|
87 |
public function setOffset($offset)
|
88 |
{
|
89 |
$current = $this->stream->tell();
|
|
|
90 |
if ($current !== $offset) {
|
91 |
// If the stream cannot seek to the offset position, then read to it
|
92 |
if ($this->stream->isSeekable()) {
|
93 |
$this->stream->seek($offset);
|
94 |
} elseif ($current > $offset) {
|
95 |
+
throw new \RuntimeException("Could not seek to stream offset {$offset}");
|
96 |
} else {
|
97 |
$this->stream->read($offset - $current);
|
98 |
}
|
99 |
}
|
|
|
100 |
$this->offset = $offset;
|
101 |
}
|
|
|
102 |
/**
|
103 |
* Set the limit of bytes that the decorator allows to be read from the
|
104 |
* stream.
|
110 |
{
|
111 |
$this->limit = $limit;
|
112 |
}
|
|
|
113 |
public function read($length)
|
114 |
{
|
115 |
if ($this->limit == -1) {
|
116 |
return $this->stream->read($length);
|
117 |
}
|
|
|
118 |
// Check if the current position is less than the total allowed
|
119 |
// bytes + original offset
|
120 |
+
$remaining = $this->offset + $this->limit - $this->stream->tell();
|
121 |
if ($remaining > 0) {
|
122 |
// Only return the amount of requested data, ensuring that the byte
|
123 |
// limit is not exceeded
|
124 |
+
return $this->stream->read(\min($remaining, $length));
|
125 |
}
|
|
|
126 |
return '';
|
127 |
}
|
128 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Message.php
RENAMED
@@ -1,11 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\MessageInterface;
|
6 |
-
use Psr\Http\Message\RequestInterface;
|
7 |
-
use Psr\Http\Message\ResponseInterface;
|
8 |
|
|
|
|
|
|
|
9 |
final class Message
|
10 |
{
|
11 |
/**
|
@@ -15,36 +14,29 @@ final class Message
|
|
15 |
*
|
16 |
* @return string
|
17 |
*/
|
18 |
-
public static function toString(MessageInterface $message)
|
19 |
{
|
20 |
-
if ($message instanceof RequestInterface) {
|
21 |
-
$msg = trim($message->getMethod() . ' '
|
22 |
-
. $message->getRequestTarget())
|
23 |
-
. ' HTTP/' . $message->getProtocolVersion();
|
24 |
if (!$message->hasHeader('host')) {
|
25 |
$msg .= "\r\nHost: " . $message->getUri()->getHost();
|
26 |
}
|
27 |
-
} elseif ($message instanceof ResponseInterface) {
|
28 |
-
$msg = 'HTTP/' . $message->getProtocolVersion() . ' '
|
29 |
-
. $message->getStatusCode() . ' '
|
30 |
-
. $message->getReasonPhrase();
|
31 |
} else {
|
32 |
throw new \InvalidArgumentException('Unknown message type');
|
33 |
}
|
34 |
-
|
35 |
foreach ($message->getHeaders() as $name => $values) {
|
36 |
-
if (strtolower($name) === 'set-cookie') {
|
37 |
foreach ($values as $value) {
|
38 |
$msg .= "\r\n{$name}: " . $value;
|
39 |
}
|
40 |
} else {
|
41 |
-
$msg .= "\r\n{$name}: " . implode(', ', $values);
|
42 |
}
|
43 |
}
|
44 |
-
|
45 |
return "{$msg}\r\n\r\n" . $message->getBody();
|
46 |
}
|
47 |
-
|
48 |
/**
|
49 |
* Get a short summary of the message body.
|
50 |
*
|
@@ -55,36 +47,28 @@ final class Message
|
|
55 |
*
|
56 |
* @return string|null
|
57 |
*/
|
58 |
-
public static function bodySummary(MessageInterface $message, $truncateAt = 120)
|
59 |
{
|
60 |
$body = $message->getBody();
|
61 |
-
|
62 |
if (!$body->isSeekable() || !$body->isReadable()) {
|
63 |
return null;
|
64 |
}
|
65 |
-
|
66 |
$size = $body->getSize();
|
67 |
-
|
68 |
if ($size === 0) {
|
69 |
return null;
|
70 |
}
|
71 |
-
|
72 |
$summary = $body->read($truncateAt);
|
73 |
$body->rewind();
|
74 |
-
|
75 |
if ($size > $truncateAt) {
|
76 |
$summary .= ' (truncated...)';
|
77 |
}
|
78 |
-
|
79 |
// Matches any printable character, including unicode characters:
|
80 |
// letters, marks, numbers, punctuation, spacing, and separators.
|
81 |
-
if (preg_match('/[
|
82 |
return null;
|
83 |
}
|
84 |
-
|
85 |
return $summary;
|
86 |
}
|
87 |
-
|
88 |
/**
|
89 |
* Attempts to rewind a message body and throws an exception on failure.
|
90 |
*
|
@@ -95,15 +79,13 @@ final class Message
|
|
95 |
*
|
96 |
* @throws \RuntimeException
|
97 |
*/
|
98 |
-
public static function rewindBody(MessageInterface $message)
|
99 |
{
|
100 |
$body = $message->getBody();
|
101 |
-
|
102 |
if ($body->tell()) {
|
103 |
$body->rewind();
|
104 |
}
|
105 |
}
|
106 |
-
|
107 |
/**
|
108 |
* Parses an HTTP message into an associative array.
|
109 |
*
|
@@ -120,56 +102,39 @@ final class Message
|
|
120 |
if (!$message) {
|
121 |
throw new \InvalidArgumentException('Invalid message');
|
122 |
}
|
123 |
-
|
124 |
-
$
|
125 |
-
|
126 |
-
$messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
|
127 |
-
|
128 |
-
if ($messageParts === false || count($messageParts) !== 2) {
|
129 |
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
|
130 |
}
|
131 |
-
|
132 |
list($rawHeaders, $body) = $messageParts;
|
133 |
-
$rawHeaders .= "\r\n";
|
134 |
-
|
135 |
-
|
136 |
-
if ($headerParts === false || count($headerParts) !== 2) {
|
137 |
throw new \InvalidArgumentException('Invalid message: Missing status line');
|
138 |
}
|
139 |
-
|
140 |
list($startLine, $rawHeaders) = $headerParts;
|
141 |
-
|
142 |
-
if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
|
143 |
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
|
144 |
-
$rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
|
145 |
}
|
146 |
-
|
147 |
/** @var array[] $headerLines */
|
148 |
-
$count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER);
|
149 |
-
|
150 |
// If these aren't the same, then one line didn't match and there's an invalid header.
|
151 |
-
if ($count !== substr_count($rawHeaders, "\n")) {
|
152 |
// Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
153 |
-
if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
|
154 |
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
|
155 |
}
|
156 |
-
|
157 |
throw new \InvalidArgumentException('Invalid header syntax');
|
158 |
}
|
159 |
-
|
160 |
$headers = [];
|
161 |
-
|
162 |
foreach ($headerLines as $headerLine) {
|
163 |
$headers[$headerLine[1]][] = $headerLine[2];
|
164 |
}
|
165 |
-
|
166 |
-
return [
|
167 |
-
'start-line' => $startLine,
|
168 |
-
'headers' => $headers,
|
169 |
-
'body' => $body,
|
170 |
-
];
|
171 |
}
|
172 |
-
|
173 |
/**
|
174 |
* Constructs a URI for an HTTP request message.
|
175 |
*
|
@@ -180,21 +145,17 @@ final class Message
|
|
180 |
*/
|
181 |
public static function parseRequestUri($path, array $headers)
|
182 |
{
|
183 |
-
$hostKey = array_filter(array_keys($headers), function ($k) {
|
184 |
-
return strtolower($k) === 'host';
|
185 |
});
|
186 |
-
|
187 |
// If no host is found, then a full URI cannot be constructed.
|
188 |
if (!$hostKey) {
|
189 |
return $path;
|
190 |
}
|
191 |
-
|
192 |
-
$
|
193 |
-
$scheme
|
194 |
-
|
195 |
-
return $scheme . '://' . $host . '/' . ltrim($path, '/');
|
196 |
}
|
197 |
-
|
198 |
/**
|
199 |
* Parses a request message string into a request object.
|
200 |
*
|
@@ -206,23 +167,14 @@ final class Message
|
|
206 |
{
|
207 |
$data = self::parseMessage($message);
|
208 |
$matches = [];
|
209 |
-
if (
|
210 |
throw new \InvalidArgumentException('Invalid request string');
|
211 |
}
|
212 |
-
$parts = explode(' ', $data['start-line'], 3);
|
213 |
-
$version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
|
214 |
-
|
215 |
-
$request = new Request(
|
216 |
-
$parts[0],
|
217 |
-
$matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1],
|
218 |
-
$data['headers'],
|
219 |
-
$data['body'],
|
220 |
-
$version
|
221 |
-
);
|
222 |
-
|
223 |
return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
|
224 |
}
|
225 |
-
|
226 |
/**
|
227 |
* Parses a response message string into a response object.
|
228 |
*
|
@@ -236,17 +188,10 @@ final class Message
|
|
236 |
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
237 |
// between status-code and reason-phrase is required. But browsers accept
|
238 |
// responses without space and reason as well.
|
239 |
-
if (
|
240 |
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
|
241 |
}
|
242 |
-
$parts = explode(' ', $data['start-line'], 3);
|
243 |
-
|
244 |
-
return new Response(
|
245 |
-
(int) $parts[1],
|
246 |
-
$data['headers'],
|
247 |
-
$data['body'],
|
248 |
-
explode('/', $parts[0])[1],
|
249 |
-
isset($parts[2]) ? $parts[2] : null
|
250 |
-
);
|
251 |
}
|
252 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
8 |
final class Message
|
9 |
{
|
10 |
/**
|
14 |
*
|
15 |
* @return string
|
16 |
*/
|
17 |
+
public static function toString(\PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface $message)
|
18 |
{
|
19 |
+
if ($message instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface) {
|
20 |
+
$msg = \trim($message->getMethod() . ' ' . $message->getRequestTarget()) . ' HTTP/' . $message->getProtocolVersion();
|
|
|
|
|
21 |
if (!$message->hasHeader('host')) {
|
22 |
$msg .= "\r\nHost: " . $message->getUri()->getHost();
|
23 |
}
|
24 |
+
} elseif ($message instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface) {
|
25 |
+
$msg = 'HTTP/' . $message->getProtocolVersion() . ' ' . $message->getStatusCode() . ' ' . $message->getReasonPhrase();
|
|
|
|
|
26 |
} else {
|
27 |
throw new \InvalidArgumentException('Unknown message type');
|
28 |
}
|
|
|
29 |
foreach ($message->getHeaders() as $name => $values) {
|
30 |
+
if (\strtolower($name) === 'set-cookie') {
|
31 |
foreach ($values as $value) {
|
32 |
$msg .= "\r\n{$name}: " . $value;
|
33 |
}
|
34 |
} else {
|
35 |
+
$msg .= "\r\n{$name}: " . \implode(', ', $values);
|
36 |
}
|
37 |
}
|
|
|
38 |
return "{$msg}\r\n\r\n" . $message->getBody();
|
39 |
}
|
|
|
40 |
/**
|
41 |
* Get a short summary of the message body.
|
42 |
*
|
47 |
*
|
48 |
* @return string|null
|
49 |
*/
|
50 |
+
public static function bodySummary(\PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface $message, $truncateAt = 120)
|
51 |
{
|
52 |
$body = $message->getBody();
|
|
|
53 |
if (!$body->isSeekable() || !$body->isReadable()) {
|
54 |
return null;
|
55 |
}
|
|
|
56 |
$size = $body->getSize();
|
|
|
57 |
if ($size === 0) {
|
58 |
return null;
|
59 |
}
|
|
|
60 |
$summary = $body->read($truncateAt);
|
61 |
$body->rewind();
|
|
|
62 |
if ($size > $truncateAt) {
|
63 |
$summary .= ' (truncated...)';
|
64 |
}
|
|
|
65 |
// Matches any printable character, including unicode characters:
|
66 |
// letters, marks, numbers, punctuation, spacing, and separators.
|
67 |
+
if (\preg_match('/[^\\pL\\pM\\pN\\pP\\pS\\pZ\\n\\r\\t]/u', $summary)) {
|
68 |
return null;
|
69 |
}
|
|
|
70 |
return $summary;
|
71 |
}
|
|
|
72 |
/**
|
73 |
* Attempts to rewind a message body and throws an exception on failure.
|
74 |
*
|
79 |
*
|
80 |
* @throws \RuntimeException
|
81 |
*/
|
82 |
+
public static function rewindBody(\PixelCaffeine\Dependencies\Psr\Http\Message\MessageInterface $message)
|
83 |
{
|
84 |
$body = $message->getBody();
|
|
|
85 |
if ($body->tell()) {
|
86 |
$body->rewind();
|
87 |
}
|
88 |
}
|
|
|
89 |
/**
|
90 |
* Parses an HTTP message into an associative array.
|
91 |
*
|
102 |
if (!$message) {
|
103 |
throw new \InvalidArgumentException('Invalid message');
|
104 |
}
|
105 |
+
$message = \ltrim($message, "\r\n");
|
106 |
+
$messageParts = \preg_split("/\r?\n\r?\n/", $message, 2);
|
107 |
+
if ($messageParts === \false || \count($messageParts) !== 2) {
|
|
|
|
|
|
|
108 |
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
|
109 |
}
|
|
|
110 |
list($rawHeaders, $body) = $messageParts;
|
111 |
+
$rawHeaders .= "\r\n";
|
112 |
+
// Put back the delimiter we split previously
|
113 |
+
$headerParts = \preg_split("/\r?\n/", $rawHeaders, 2);
|
114 |
+
if ($headerParts === \false || \count($headerParts) !== 2) {
|
115 |
throw new \InvalidArgumentException('Invalid message: Missing status line');
|
116 |
}
|
|
|
117 |
list($startLine, $rawHeaders) = $headerParts;
|
118 |
+
if (\preg_match("/(?:^HTTP\\/|^[A-Z]+ \\S+ HTTP\\/)(\\d+(?:\\.\\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
|
|
|
119 |
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
|
120 |
+
$rawHeaders = \preg_replace(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
|
121 |
}
|
|
|
122 |
/** @var array[] $headerLines */
|
123 |
+
$count = \preg_match_all(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, \PREG_SET_ORDER);
|
|
|
124 |
// If these aren't the same, then one line didn't match and there's an invalid header.
|
125 |
+
if ($count !== \substr_count($rawHeaders, "\n")) {
|
126 |
// Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
127 |
+
if (\preg_match(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
|
128 |
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
|
129 |
}
|
|
|
130 |
throw new \InvalidArgumentException('Invalid header syntax');
|
131 |
}
|
|
|
132 |
$headers = [];
|
|
|
133 |
foreach ($headerLines as $headerLine) {
|
134 |
$headers[$headerLine[1]][] = $headerLine[2];
|
135 |
}
|
136 |
+
return ['start-line' => $startLine, 'headers' => $headers, 'body' => $body];
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
|
|
138 |
/**
|
139 |
* Constructs a URI for an HTTP request message.
|
140 |
*
|
145 |
*/
|
146 |
public static function parseRequestUri($path, array $headers)
|
147 |
{
|
148 |
+
$hostKey = \array_filter(\array_keys($headers), function ($k) {
|
149 |
+
return \strtolower($k) === 'host';
|
150 |
});
|
|
|
151 |
// If no host is found, then a full URI cannot be constructed.
|
152 |
if (!$hostKey) {
|
153 |
return $path;
|
154 |
}
|
155 |
+
$host = $headers[\reset($hostKey)][0];
|
156 |
+
$scheme = \substr($host, -4) === ':443' ? 'https' : 'http';
|
157 |
+
return $scheme . '://' . $host . '/' . \ltrim($path, '/');
|
|
|
|
|
158 |
}
|
|
|
159 |
/**
|
160 |
* Parses a request message string into a request object.
|
161 |
*
|
167 |
{
|
168 |
$data = self::parseMessage($message);
|
169 |
$matches = [];
|
170 |
+
if (!\preg_match('/^[\\S]+\\s+([a-zA-Z]+:\\/\\/|\\/).*/', $data['start-line'], $matches)) {
|
171 |
throw new \InvalidArgumentException('Invalid request string');
|
172 |
}
|
173 |
+
$parts = \explode(' ', $data['start-line'], 3);
|
174 |
+
$version = isset($parts[2]) ? \explode('/', $parts[2])[1] : '1.1';
|
175 |
+
$request = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Request($parts[0], $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1], $data['headers'], $data['body'], $version);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
|
177 |
}
|
|
|
178 |
/**
|
179 |
* Parses a response message string into a response object.
|
180 |
*
|
188 |
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
189 |
// between status-code and reason-phrase is required. But browsers accept
|
190 |
// responses without space and reason as well.
|
191 |
+
if (!\preg_match('/^HTTP\\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
|
192 |
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
|
193 |
}
|
194 |
+
$parts = \explode(' ', $data['start-line'], 3);
|
195 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Response((int) $parts[1], $data['headers'], $data['body'], \explode('/', $parts[0])[1], isset($parts[2]) ? $parts[2] : null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/MessageTrait.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Trait implementing functionality common to requests and responses.
|
9 |
*/
|
@@ -11,165 +10,132 @@ trait MessageTrait
|
|
11 |
{
|
12 |
/** @var array Map of all registered headers, as original name => array of values */
|
13 |
private $headers = [];
|
14 |
-
|
15 |
/** @var array Map of lowercase header name => original name at registration */
|
16 |
-
private $headerNames
|
17 |
-
|
18 |
/** @var string */
|
19 |
private $protocol = '1.1';
|
20 |
-
|
21 |
/** @var StreamInterface|null */
|
22 |
private $stream;
|
23 |
-
|
24 |
public function getProtocolVersion()
|
25 |
{
|
26 |
return $this->protocol;
|
27 |
}
|
28 |
-
|
29 |
public function withProtocolVersion($version)
|
30 |
{
|
31 |
if ($this->protocol === $version) {
|
32 |
return $this;
|
33 |
}
|
34 |
-
|
35 |
$new = clone $this;
|
36 |
$new->protocol = $version;
|
37 |
return $new;
|
38 |
}
|
39 |
-
|
40 |
public function getHeaders()
|
41 |
{
|
42 |
return $this->headers;
|
43 |
}
|
44 |
-
|
45 |
public function hasHeader($header)
|
46 |
{
|
47 |
-
return isset($this->headerNames[strtolower($header)]);
|
48 |
}
|
49 |
-
|
50 |
public function getHeader($header)
|
51 |
{
|
52 |
-
$header = strtolower($header);
|
53 |
-
|
54 |
if (!isset($this->headerNames[$header])) {
|
55 |
return [];
|
56 |
}
|
57 |
-
|
58 |
$header = $this->headerNames[$header];
|
59 |
-
|
60 |
return $this->headers[$header];
|
61 |
}
|
62 |
-
|
63 |
public function getHeaderLine($header)
|
64 |
{
|
65 |
-
return implode(', ', $this->getHeader($header));
|
66 |
}
|
67 |
-
|
68 |
public function withHeader($header, $value)
|
69 |
{
|
70 |
$this->assertHeader($header);
|
71 |
$value = $this->normalizeHeaderValue($value);
|
72 |
-
$normalized = strtolower($header);
|
73 |
-
|
74 |
$new = clone $this;
|
75 |
if (isset($new->headerNames[$normalized])) {
|
76 |
unset($new->headers[$new->headerNames[$normalized]]);
|
77 |
}
|
78 |
$new->headerNames[$normalized] = $header;
|
79 |
$new->headers[$header] = $value;
|
80 |
-
|
81 |
return $new;
|
82 |
}
|
83 |
-
|
84 |
public function withAddedHeader($header, $value)
|
85 |
{
|
86 |
$this->assertHeader($header);
|
87 |
$value = $this->normalizeHeaderValue($value);
|
88 |
-
$normalized = strtolower($header);
|
89 |
-
|
90 |
$new = clone $this;
|
91 |
if (isset($new->headerNames[$normalized])) {
|
92 |
$header = $this->headerNames[$normalized];
|
93 |
-
$new->headers[$header] = array_merge($this->headers[$header], $value);
|
94 |
} else {
|
95 |
$new->headerNames[$normalized] = $header;
|
96 |
$new->headers[$header] = $value;
|
97 |
}
|
98 |
-
|
99 |
return $new;
|
100 |
}
|
101 |
-
|
102 |
public function withoutHeader($header)
|
103 |
{
|
104 |
-
$normalized = strtolower($header);
|
105 |
-
|
106 |
if (!isset($this->headerNames[$normalized])) {
|
107 |
return $this;
|
108 |
}
|
109 |
-
|
110 |
$header = $this->headerNames[$normalized];
|
111 |
-
|
112 |
$new = clone $this;
|
113 |
unset($new->headers[$header], $new->headerNames[$normalized]);
|
114 |
-
|
115 |
return $new;
|
116 |
}
|
117 |
-
|
118 |
public function getBody()
|
119 |
{
|
120 |
if (!$this->stream) {
|
121 |
-
$this->stream = Utils::streamFor('');
|
122 |
}
|
123 |
-
|
124 |
return $this->stream;
|
125 |
}
|
126 |
-
|
127 |
-
public function withBody(StreamInterface $body)
|
128 |
{
|
129 |
if ($body === $this->stream) {
|
130 |
return $this;
|
131 |
}
|
132 |
-
|
133 |
$new = clone $this;
|
134 |
$new->stream = $body;
|
135 |
return $new;
|
136 |
}
|
137 |
-
|
138 |
private function setHeaders(array $headers)
|
139 |
{
|
140 |
$this->headerNames = $this->headers = [];
|
141 |
foreach ($headers as $header => $value) {
|
142 |
-
if (is_int($header)) {
|
143 |
// Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
|
144 |
// and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
|
145 |
$header = (string) $header;
|
146 |
}
|
147 |
$this->assertHeader($header);
|
148 |
$value = $this->normalizeHeaderValue($value);
|
149 |
-
$normalized = strtolower($header);
|
150 |
if (isset($this->headerNames[$normalized])) {
|
151 |
$header = $this->headerNames[$normalized];
|
152 |
-
$this->headers[$header] = array_merge($this->headers[$header], $value);
|
153 |
} else {
|
154 |
$this->headerNames[$normalized] = $header;
|
155 |
$this->headers[$header] = $value;
|
156 |
}
|
157 |
}
|
158 |
}
|
159 |
-
|
160 |
private function normalizeHeaderValue($value)
|
161 |
{
|
162 |
-
if (
|
163 |
return $this->trimHeaderValues([$value]);
|
164 |
}
|
165 |
-
|
166 |
-
if (count($value) === 0) {
|
167 |
throw new \InvalidArgumentException('Header value can not be an empty array.');
|
168 |
}
|
169 |
-
|
170 |
return $this->trimHeaderValues($value);
|
171 |
}
|
172 |
-
|
173 |
/**
|
174 |
* Trims whitespace from the header values.
|
175 |
*
|
@@ -186,27 +152,18 @@ trait MessageTrait
|
|
186 |
*/
|
187 |
private function trimHeaderValues(array $values)
|
188 |
{
|
189 |
-
return array_map(function ($value) {
|
190 |
-
if (
|
191 |
-
throw new \InvalidArgumentException(sprintf(
|
192 |
-
'Header value must be scalar or null but %s provided.',
|
193 |
-
is_object($value) ? get_class($value) : gettype($value)
|
194 |
-
));
|
195 |
}
|
196 |
-
|
197 |
-
|
198 |
-
}, array_values($values));
|
199 |
}
|
200 |
-
|
201 |
private function assertHeader($header)
|
202 |
{
|
203 |
-
if (
|
204 |
-
throw new \InvalidArgumentException(sprintf(
|
205 |
-
'Header name must be a string but %s provided.',
|
206 |
-
is_object($header) ? get_class($header) : gettype($header)
|
207 |
-
));
|
208 |
}
|
209 |
-
|
210 |
if ($header === '') {
|
211 |
throw new \InvalidArgumentException('Header name can not be empty.');
|
212 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Trait implementing functionality common to requests and responses.
|
8 |
*/
|
10 |
{
|
11 |
/** @var array Map of all registered headers, as original name => array of values */
|
12 |
private $headers = [];
|
|
|
13 |
/** @var array Map of lowercase header name => original name at registration */
|
14 |
+
private $headerNames = [];
|
|
|
15 |
/** @var string */
|
16 |
private $protocol = '1.1';
|
|
|
17 |
/** @var StreamInterface|null */
|
18 |
private $stream;
|
|
|
19 |
public function getProtocolVersion()
|
20 |
{
|
21 |
return $this->protocol;
|
22 |
}
|
|
|
23 |
public function withProtocolVersion($version)
|
24 |
{
|
25 |
if ($this->protocol === $version) {
|
26 |
return $this;
|
27 |
}
|
|
|
28 |
$new = clone $this;
|
29 |
$new->protocol = $version;
|
30 |
return $new;
|
31 |
}
|
|
|
32 |
public function getHeaders()
|
33 |
{
|
34 |
return $this->headers;
|
35 |
}
|
|
|
36 |
public function hasHeader($header)
|
37 |
{
|
38 |
+
return isset($this->headerNames[\strtolower($header)]);
|
39 |
}
|
|
|
40 |
public function getHeader($header)
|
41 |
{
|
42 |
+
$header = \strtolower($header);
|
|
|
43 |
if (!isset($this->headerNames[$header])) {
|
44 |
return [];
|
45 |
}
|
|
|
46 |
$header = $this->headerNames[$header];
|
|
|
47 |
return $this->headers[$header];
|
48 |
}
|
|
|
49 |
public function getHeaderLine($header)
|
50 |
{
|
51 |
+
return \implode(', ', $this->getHeader($header));
|
52 |
}
|
|
|
53 |
public function withHeader($header, $value)
|
54 |
{
|
55 |
$this->assertHeader($header);
|
56 |
$value = $this->normalizeHeaderValue($value);
|
57 |
+
$normalized = \strtolower($header);
|
|
|
58 |
$new = clone $this;
|
59 |
if (isset($new->headerNames[$normalized])) {
|
60 |
unset($new->headers[$new->headerNames[$normalized]]);
|
61 |
}
|
62 |
$new->headerNames[$normalized] = $header;
|
63 |
$new->headers[$header] = $value;
|
|
|
64 |
return $new;
|
65 |
}
|
|
|
66 |
public function withAddedHeader($header, $value)
|
67 |
{
|
68 |
$this->assertHeader($header);
|
69 |
$value = $this->normalizeHeaderValue($value);
|
70 |
+
$normalized = \strtolower($header);
|
|
|
71 |
$new = clone $this;
|
72 |
if (isset($new->headerNames[$normalized])) {
|
73 |
$header = $this->headerNames[$normalized];
|
74 |
+
$new->headers[$header] = \array_merge($this->headers[$header], $value);
|
75 |
} else {
|
76 |
$new->headerNames[$normalized] = $header;
|
77 |
$new->headers[$header] = $value;
|
78 |
}
|
|
|
79 |
return $new;
|
80 |
}
|
|
|
81 |
public function withoutHeader($header)
|
82 |
{
|
83 |
+
$normalized = \strtolower($header);
|
|
|
84 |
if (!isset($this->headerNames[$normalized])) {
|
85 |
return $this;
|
86 |
}
|
|
|
87 |
$header = $this->headerNames[$normalized];
|
|
|
88 |
$new = clone $this;
|
89 |
unset($new->headers[$header], $new->headerNames[$normalized]);
|
|
|
90 |
return $new;
|
91 |
}
|
|
|
92 |
public function getBody()
|
93 |
{
|
94 |
if (!$this->stream) {
|
95 |
+
$this->stream = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor('');
|
96 |
}
|
|
|
97 |
return $this->stream;
|
98 |
}
|
99 |
+
public function withBody(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $body)
|
|
|
100 |
{
|
101 |
if ($body === $this->stream) {
|
102 |
return $this;
|
103 |
}
|
|
|
104 |
$new = clone $this;
|
105 |
$new->stream = $body;
|
106 |
return $new;
|
107 |
}
|
|
|
108 |
private function setHeaders(array $headers)
|
109 |
{
|
110 |
$this->headerNames = $this->headers = [];
|
111 |
foreach ($headers as $header => $value) {
|
112 |
+
if (\is_int($header)) {
|
113 |
// Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
|
114 |
// and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
|
115 |
$header = (string) $header;
|
116 |
}
|
117 |
$this->assertHeader($header);
|
118 |
$value = $this->normalizeHeaderValue($value);
|
119 |
+
$normalized = \strtolower($header);
|
120 |
if (isset($this->headerNames[$normalized])) {
|
121 |
$header = $this->headerNames[$normalized];
|
122 |
+
$this->headers[$header] = \array_merge($this->headers[$header], $value);
|
123 |
} else {
|
124 |
$this->headerNames[$normalized] = $header;
|
125 |
$this->headers[$header] = $value;
|
126 |
}
|
127 |
}
|
128 |
}
|
|
|
129 |
private function normalizeHeaderValue($value)
|
130 |
{
|
131 |
+
if (!\is_array($value)) {
|
132 |
return $this->trimHeaderValues([$value]);
|
133 |
}
|
134 |
+
if (\count($value) === 0) {
|
|
|
135 |
throw new \InvalidArgumentException('Header value can not be an empty array.');
|
136 |
}
|
|
|
137 |
return $this->trimHeaderValues($value);
|
138 |
}
|
|
|
139 |
/**
|
140 |
* Trims whitespace from the header values.
|
141 |
*
|
152 |
*/
|
153 |
private function trimHeaderValues(array $values)
|
154 |
{
|
155 |
+
return \array_map(function ($value) {
|
156 |
+
if (!\is_scalar($value) && null !== $value) {
|
157 |
+
throw new \InvalidArgumentException(\sprintf('Header value must be scalar or null but %s provided.', \is_object($value) ? \get_class($value) : \gettype($value)));
|
|
|
|
|
|
|
158 |
}
|
159 |
+
return \trim((string) $value, " \t");
|
160 |
+
}, \array_values($values));
|
|
|
161 |
}
|
|
|
162 |
private function assertHeader($header)
|
163 |
{
|
164 |
+
if (!\is_string($header)) {
|
165 |
+
throw new \InvalidArgumentException(\sprintf('Header name must be a string but %s provided.', \is_object($header) ? \get_class($header) : \gettype($header)));
|
|
|
|
|
|
|
166 |
}
|
|
|
167 |
if ($header === '') {
|
168 |
throw new \InvalidArgumentException('Header name can not be empty.');
|
169 |
}
|
third-party/vendor/guzzlehttp/psr7/src/MimeType.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
+
|
5 |
+
final class MimeType
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Determines the mimetype of a file by looking at its extension.
|
9 |
+
*
|
10 |
+
* @param string $filename
|
11 |
+
*
|
12 |
+
* @return string|null
|
13 |
+
*/
|
14 |
+
public static function fromFilename($filename)
|
15 |
+
{
|
16 |
+
return self::fromExtension(\pathinfo($filename, \PATHINFO_EXTENSION));
|
17 |
+
}
|
18 |
+
/**
|
19 |
+
* Maps a file extensions to a mimetype.
|
20 |
+
*
|
21 |
+
* @param string $extension string The file extension.
|
22 |
+
*
|
23 |
+
* @return string|null
|
24 |
+
*
|
25 |
+
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
26 |
+
*/
|
27 |
+
public static function fromExtension($extension)
|
28 |
+
{
|
29 |
+
static $mimetypes = ['3gp' => 'video/3gpp', '7z' => 'application/x-7z-compressed', 'aac' => 'audio/x-aac', 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff', 'asc' => 'text/plain', 'asf' => 'video/x-ms-asf', 'atom' => 'application/atom+xml', 'avi' => 'video/x-msvideo', 'bmp' => 'image/bmp', 'bz2' => 'application/x-bzip2', 'cer' => 'application/pkix-cert', 'crl' => 'application/pkix-crl', 'crt' => 'application/x-x509-ca-cert', 'css' => 'text/css', 'csv' => 'text/csv', 'cu' => 'application/cu-seeme', 'deb' => 'application/x-debian-package', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dvi' => 'application/x-dvi', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript', 'epub' => 'application/epub+zip', 'etx' => 'text/x-setext', 'flac' => 'audio/flac', 'flv' => 'video/x-flv', 'gif' => 'image/gif', 'gz' => 'application/gzip', 'htm' => 'text/html', 'html' => 'text/html', 'ico' => 'image/x-icon', 'ics' => 'text/calendar', 'ini' => 'text/plain', 'iso' => 'application/x-iso9660-image', 'jar' => 'application/java-archive', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'js' => 'text/javascript', 'json' => 'application/json', 'latex' => 'application/x-latex', 'log' => 'text/plain', 'm4a' => 'audio/mp4', 'm4v' => 'video/mp4', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mov' => 'video/quicktime', 'mkv' => 'video/x-matroska', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'mp4a' => 'audio/mp4', 'mp4v' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpg4' => 'video/mp4', 'oga' => 'audio/ogg', 'ogg' => 'audio/ogg', 'ogv' => 'video/ogg', 'ogx' => 'application/ogg', 'pbm' => 'image/x-portable-bitmap', 'pdf' => 'application/pdf', 'pgm' => 'image/x-portable-graymap', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'ppm' => 'image/x-portable-pixmap', 'ppt' => 'application/vnd.ms-powerpoint', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'ps' => 'application/postscript', 'qt' => 'video/quicktime', 'rar' => 'application/x-rar-compressed', 'ras' => 'image/x-cmu-raster', 'rss' => 'application/rss+xml', 'rtf' => 'application/rtf', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'svg' => 'image/svg+xml', 'swf' => 'application/x-shockwave-flash', 'tar' => 'application/x-tar', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'torrent' => 'application/x-bittorrent', 'ttf' => 'application/x-font-ttf', 'txt' => 'text/plain', 'wav' => 'audio/x-wav', 'webm' => 'video/webm', 'webp' => 'image/webp', 'wma' => 'audio/x-ms-wma', 'wmv' => 'video/x-ms-wmv', 'woff' => 'application/x-font-woff', 'wsdl' => 'application/wsdl+xml', 'xbm' => 'image/x-xbitmap', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'yaml' => 'text/yaml', 'yml' => 'text/yaml', 'zip' => 'application/zip'];
|
30 |
+
$extension = \strtolower($extension);
|
31 |
+
return isset($mimetypes[$extension]) ? $mimetypes[$extension] : null;
|
32 |
+
}
|
33 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/MultipartStream.php
RENAMED
@@ -1,19 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Stream that when read returns bytes for a streaming multipart or
|
9 |
* multipart/form-data stream.
|
10 |
*/
|
11 |
-
class MultipartStream implements StreamInterface
|
12 |
{
|
13 |
use StreamDecoratorTrait;
|
14 |
-
|
15 |
private $boundary;
|
16 |
-
|
17 |
/**
|
18 |
* @param array $elements Array of associative arrays, each containing a
|
19 |
* required "name" key mapping to the form field,
|
@@ -28,10 +25,9 @@ class MultipartStream implements StreamInterface
|
|
28 |
*/
|
29 |
public function __construct(array $elements = [], $boundary = null)
|
30 |
{
|
31 |
-
$this->boundary = $boundary ?: sha1(uniqid('', true));
|
32 |
$this->stream = $this->createStream($elements);
|
33 |
}
|
34 |
-
|
35 |
/**
|
36 |
* Get the boundary
|
37 |
*
|
@@ -41,12 +37,10 @@ class MultipartStream implements StreamInterface
|
|
41 |
{
|
42 |
return $this->boundary;
|
43 |
}
|
44 |
-
|
45 |
public function isWritable()
|
46 |
{
|
47 |
-
return false;
|
48 |
}
|
49 |
-
|
50 |
/**
|
51 |
* Get the headers needed before transferring the content of a POST file
|
52 |
*/
|
@@ -56,71 +50,50 @@ class MultipartStream implements StreamInterface
|
|
56 |
foreach ($headers as $key => $value) {
|
57 |
$str .= "{$key}: {$value}\r\n";
|
58 |
}
|
59 |
-
|
60 |
-
return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
|
61 |
}
|
62 |
-
|
63 |
/**
|
64 |
* Create the aggregate stream that will be used to upload the POST data
|
65 |
*/
|
66 |
protected function createStream(array $elements)
|
67 |
{
|
68 |
-
$stream = new AppendStream();
|
69 |
-
|
70 |
foreach ($elements as $element) {
|
71 |
$this->addElement($stream, $element);
|
72 |
}
|
73 |
-
|
74 |
// Add the trailing boundary with CRLF
|
75 |
-
$stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n"));
|
76 |
-
|
77 |
return $stream;
|
78 |
}
|
79 |
-
|
80 |
-
private function addElement(AppendStream $stream, array $element)
|
81 |
{
|
82 |
foreach (['contents', 'name'] as $key) {
|
83 |
-
if (
|
84 |
throw new \InvalidArgumentException("A '{$key}' key is required");
|
85 |
}
|
86 |
}
|
87 |
-
|
88 |
-
$element['contents'] = Utils::streamFor($element['contents']);
|
89 |
-
|
90 |
if (empty($element['filename'])) {
|
91 |
$uri = $element['contents']->getMetadata('uri');
|
92 |
-
if (substr($uri, 0, 6) !== 'php://') {
|
93 |
$element['filename'] = $uri;
|
94 |
}
|
95 |
}
|
96 |
-
|
97 |
-
|
98 |
-
$element['name'],
|
99 |
-
$element['contents'],
|
100 |
-
isset($element['filename']) ? $element['filename'] : null,
|
101 |
-
isset($element['headers']) ? $element['headers'] : []
|
102 |
-
);
|
103 |
-
|
104 |
-
$stream->addStream(Utils::streamFor($this->getHeaders($headers)));
|
105 |
$stream->addStream($body);
|
106 |
-
$stream->addStream(Utils::streamFor("\r\n"));
|
107 |
}
|
108 |
-
|
109 |
/**
|
110 |
* @return array
|
111 |
*/
|
112 |
-
private function createElement($name, StreamInterface $stream, $filename, array $headers)
|
113 |
{
|
114 |
// Set a default content-disposition header if one was no provided
|
115 |
$disposition = $this->getHeader($headers, 'content-disposition');
|
116 |
if (!$disposition) {
|
117 |
-
$headers['Content-Disposition'] =
|
118 |
-
? sprintf('form-data; name="%s"; filename="%s"',
|
119 |
-
$name,
|
120 |
-
basename($filename))
|
121 |
-
: "form-data; name=\"{$name}\"";
|
122 |
}
|
123 |
-
|
124 |
// Set a default content-length header if one was no provided
|
125 |
$length = $this->getHeader($headers, 'content-length');
|
126 |
if (!$length) {
|
@@ -128,27 +101,23 @@ class MultipartStream implements StreamInterface
|
|
128 |
$headers['Content-Length'] = (string) $length;
|
129 |
}
|
130 |
}
|
131 |
-
|
132 |
// Set a default Content-Type if one was not supplied
|
133 |
$type = $this->getHeader($headers, 'content-type');
|
134 |
if (!$type && ($filename === '0' || $filename)) {
|
135 |
-
if ($type = MimeType::fromFilename($filename)) {
|
136 |
$headers['Content-Type'] = $type;
|
137 |
}
|
138 |
}
|
139 |
-
|
140 |
return [$stream, $headers];
|
141 |
}
|
142 |
-
|
143 |
private function getHeader(array $headers, $key)
|
144 |
{
|
145 |
-
$lowercaseHeader = strtolower($key);
|
146 |
foreach ($headers as $k => $v) {
|
147 |
-
if (strtolower($k) === $lowercaseHeader) {
|
148 |
return $v;
|
149 |
}
|
150 |
}
|
151 |
-
|
152 |
return null;
|
153 |
}
|
154 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Stream that when read returns bytes for a streaming multipart or
|
8 |
* multipart/form-data stream.
|
9 |
*/
|
10 |
+
class MultipartStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
11 |
{
|
12 |
use StreamDecoratorTrait;
|
|
|
13 |
private $boundary;
|
|
|
14 |
/**
|
15 |
* @param array $elements Array of associative arrays, each containing a
|
16 |
* required "name" key mapping to the form field,
|
25 |
*/
|
26 |
public function __construct(array $elements = [], $boundary = null)
|
27 |
{
|
28 |
+
$this->boundary = $boundary ?: \sha1(\uniqid('', \true));
|
29 |
$this->stream = $this->createStream($elements);
|
30 |
}
|
|
|
31 |
/**
|
32 |
* Get the boundary
|
33 |
*
|
37 |
{
|
38 |
return $this->boundary;
|
39 |
}
|
|
|
40 |
public function isWritable()
|
41 |
{
|
42 |
+
return \false;
|
43 |
}
|
|
|
44 |
/**
|
45 |
* Get the headers needed before transferring the content of a POST file
|
46 |
*/
|
50 |
foreach ($headers as $key => $value) {
|
51 |
$str .= "{$key}: {$value}\r\n";
|
52 |
}
|
53 |
+
return "--{$this->boundary}\r\n" . \trim($str) . "\r\n\r\n";
|
|
|
54 |
}
|
|
|
55 |
/**
|
56 |
* Create the aggregate stream that will be used to upload the POST data
|
57 |
*/
|
58 |
protected function createStream(array $elements)
|
59 |
{
|
60 |
+
$stream = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\AppendStream();
|
|
|
61 |
foreach ($elements as $element) {
|
62 |
$this->addElement($stream, $element);
|
63 |
}
|
|
|
64 |
// Add the trailing boundary with CRLF
|
65 |
+
$stream->addStream(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor("--{$this->boundary}--\r\n"));
|
|
|
66 |
return $stream;
|
67 |
}
|
68 |
+
private function addElement(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\AppendStream $stream, array $element)
|
|
|
69 |
{
|
70 |
foreach (['contents', 'name'] as $key) {
|
71 |
+
if (!\array_key_exists($key, $element)) {
|
72 |
throw new \InvalidArgumentException("A '{$key}' key is required");
|
73 |
}
|
74 |
}
|
75 |
+
$element['contents'] = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor($element['contents']);
|
|
|
|
|
76 |
if (empty($element['filename'])) {
|
77 |
$uri = $element['contents']->getMetadata('uri');
|
78 |
+
if (\substr($uri, 0, 6) !== 'php://') {
|
79 |
$element['filename'] = $uri;
|
80 |
}
|
81 |
}
|
82 |
+
list($body, $headers) = $this->createElement($element['name'], $element['contents'], isset($element['filename']) ? $element['filename'] : null, isset($element['headers']) ? $element['headers'] : []);
|
83 |
+
$stream->addStream(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor($this->getHeaders($headers)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
$stream->addStream($body);
|
85 |
+
$stream->addStream(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor("\r\n"));
|
86 |
}
|
|
|
87 |
/**
|
88 |
* @return array
|
89 |
*/
|
90 |
+
private function createElement($name, \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream, $filename, array $headers)
|
91 |
{
|
92 |
// Set a default content-disposition header if one was no provided
|
93 |
$disposition = $this->getHeader($headers, 'content-disposition');
|
94 |
if (!$disposition) {
|
95 |
+
$headers['Content-Disposition'] = $filename === '0' || $filename ? \sprintf('form-data; name="%s"; filename="%s"', $name, \basename($filename)) : "form-data; name=\"{$name}\"";
|
|
|
|
|
|
|
|
|
96 |
}
|
|
|
97 |
// Set a default content-length header if one was no provided
|
98 |
$length = $this->getHeader($headers, 'content-length');
|
99 |
if (!$length) {
|
101 |
$headers['Content-Length'] = (string) $length;
|
102 |
}
|
103 |
}
|
|
|
104 |
// Set a default Content-Type if one was not supplied
|
105 |
$type = $this->getHeader($headers, 'content-type');
|
106 |
if (!$type && ($filename === '0' || $filename)) {
|
107 |
+
if ($type = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\MimeType::fromFilename($filename)) {
|
108 |
$headers['Content-Type'] = $type;
|
109 |
}
|
110 |
}
|
|
|
111 |
return [$stream, $headers];
|
112 |
}
|
|
|
113 |
private function getHeader(array $headers, $key)
|
114 |
{
|
115 |
+
$lowercaseHeader = \strtolower($key);
|
116 |
foreach ($headers as $k => $v) {
|
117 |
+
if (\strtolower($k) === $lowercaseHeader) {
|
118 |
return $v;
|
119 |
}
|
120 |
}
|
|
|
121 |
return null;
|
122 |
}
|
123 |
}
|
third-party/vendor/guzzlehttp/psr7/src/NoSeekStream.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
+
/**
|
7 |
+
* Stream decorator that prevents a stream from being seeked
|
8 |
+
*/
|
9 |
+
class NoSeekStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
10 |
+
{
|
11 |
+
use StreamDecoratorTrait;
|
12 |
+
public function seek($offset, $whence = \SEEK_SET)
|
13 |
+
{
|
14 |
+
throw new \RuntimeException('Cannot seek a NoSeekStream');
|
15 |
+
}
|
16 |
+
public function isSeekable()
|
17 |
+
{
|
18 |
+
return \false;
|
19 |
+
}
|
20 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/PumpStream.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Provides a read only stream that pumps data from a PHP callable.
|
9 |
*
|
@@ -14,23 +13,18 @@ use Psr\Http\Message\StreamInterface;
|
|
14 |
* the read() function of the PumpStream. The provided callable MUST return
|
15 |
* false when there is no more data to read.
|
16 |
*/
|
17 |
-
class PumpStream implements StreamInterface
|
18 |
{
|
19 |
/** @var callable */
|
20 |
private $source;
|
21 |
-
|
22 |
/** @var int */
|
23 |
private $size;
|
24 |
-
|
25 |
/** @var int */
|
26 |
private $tellPos = 0;
|
27 |
-
|
28 |
/** @var array */
|
29 |
private $metadata;
|
30 |
-
|
31 |
/** @var BufferStream */
|
32 |
private $buffer;
|
33 |
-
|
34 |
/**
|
35 |
* @param callable $source Source of the stream data. The callable MAY
|
36 |
* accept an integer argument used to control the
|
@@ -46,122 +40,101 @@ class PumpStream implements StreamInterface
|
|
46 |
$this->source = $source;
|
47 |
$this->size = isset($options['size']) ? $options['size'] : null;
|
48 |
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
|
49 |
-
$this->buffer = new BufferStream();
|
50 |
}
|
51 |
-
|
52 |
public function __toString()
|
53 |
{
|
54 |
try {
|
55 |
-
return Utils::copyToString($this);
|
56 |
} catch (\Exception $e) {
|
57 |
return '';
|
58 |
}
|
59 |
}
|
60 |
-
|
61 |
public function close()
|
62 |
{
|
63 |
$this->detach();
|
64 |
}
|
65 |
-
|
66 |
public function detach()
|
67 |
{
|
68 |
-
$this->tellPos = false;
|
69 |
$this->source = null;
|
70 |
-
|
71 |
return null;
|
72 |
}
|
73 |
-
|
74 |
public function getSize()
|
75 |
{
|
76 |
return $this->size;
|
77 |
}
|
78 |
-
|
79 |
public function tell()
|
80 |
{
|
81 |
return $this->tellPos;
|
82 |
}
|
83 |
-
|
84 |
public function eof()
|
85 |
{
|
86 |
return !$this->source;
|
87 |
}
|
88 |
-
|
89 |
public function isSeekable()
|
90 |
{
|
91 |
-
return false;
|
92 |
}
|
93 |
-
|
94 |
public function rewind()
|
95 |
{
|
96 |
$this->seek(0);
|
97 |
}
|
98 |
-
|
99 |
-
public function seek($offset, $whence = SEEK_SET)
|
100 |
{
|
101 |
throw new \RuntimeException('Cannot seek a PumpStream');
|
102 |
}
|
103 |
-
|
104 |
public function isWritable()
|
105 |
{
|
106 |
-
return false;
|
107 |
}
|
108 |
-
|
109 |
public function write($string)
|
110 |
{
|
111 |
throw new \RuntimeException('Cannot write to a PumpStream');
|
112 |
}
|
113 |
-
|
114 |
public function isReadable()
|
115 |
{
|
116 |
-
return true;
|
117 |
}
|
118 |
-
|
119 |
public function read($length)
|
120 |
{
|
121 |
$data = $this->buffer->read($length);
|
122 |
-
$readLen = strlen($data);
|
123 |
$this->tellPos += $readLen;
|
124 |
$remaining = $length - $readLen;
|
125 |
-
|
126 |
if ($remaining) {
|
127 |
$this->pump($remaining);
|
128 |
$data .= $this->buffer->read($remaining);
|
129 |
-
$this->tellPos += strlen($data) - $readLen;
|
130 |
}
|
131 |
-
|
132 |
return $data;
|
133 |
}
|
134 |
-
|
135 |
public function getContents()
|
136 |
{
|
137 |
$result = '';
|
138 |
while (!$this->eof()) {
|
139 |
$result .= $this->read(1000000);
|
140 |
}
|
141 |
-
|
142 |
return $result;
|
143 |
}
|
144 |
-
|
145 |
public function getMetadata($key = null)
|
146 |
{
|
147 |
if (!$key) {
|
148 |
return $this->metadata;
|
149 |
}
|
150 |
-
|
151 |
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
|
152 |
}
|
153 |
-
|
154 |
private function pump($length)
|
155 |
{
|
156 |
if ($this->source) {
|
157 |
do {
|
158 |
-
$data = call_user_func($this->source, $length);
|
159 |
-
if ($data === false || $data === null) {
|
160 |
$this->source = null;
|
161 |
return;
|
162 |
}
|
163 |
$this->buffer->write($data);
|
164 |
-
$length -= strlen($data);
|
165 |
} while ($length > 0);
|
166 |
}
|
167 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Provides a read only stream that pumps data from a PHP callable.
|
8 |
*
|
13 |
* the read() function of the PumpStream. The provided callable MUST return
|
14 |
* false when there is no more data to read.
|
15 |
*/
|
16 |
+
class PumpStream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
17 |
{
|
18 |
/** @var callable */
|
19 |
private $source;
|
|
|
20 |
/** @var int */
|
21 |
private $size;
|
|
|
22 |
/** @var int */
|
23 |
private $tellPos = 0;
|
|
|
24 |
/** @var array */
|
25 |
private $metadata;
|
|
|
26 |
/** @var BufferStream */
|
27 |
private $buffer;
|
|
|
28 |
/**
|
29 |
* @param callable $source Source of the stream data. The callable MAY
|
30 |
* accept an integer argument used to control the
|
40 |
$this->source = $source;
|
41 |
$this->size = isset($options['size']) ? $options['size'] : null;
|
42 |
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
|
43 |
+
$this->buffer = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\BufferStream();
|
44 |
}
|
|
|
45 |
public function __toString()
|
46 |
{
|
47 |
try {
|
48 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::copyToString($this);
|
49 |
} catch (\Exception $e) {
|
50 |
return '';
|
51 |
}
|
52 |
}
|
|
|
53 |
public function close()
|
54 |
{
|
55 |
$this->detach();
|
56 |
}
|
|
|
57 |
public function detach()
|
58 |
{
|
59 |
+
$this->tellPos = \false;
|
60 |
$this->source = null;
|
|
|
61 |
return null;
|
62 |
}
|
|
|
63 |
public function getSize()
|
64 |
{
|
65 |
return $this->size;
|
66 |
}
|
|
|
67 |
public function tell()
|
68 |
{
|
69 |
return $this->tellPos;
|
70 |
}
|
|
|
71 |
public function eof()
|
72 |
{
|
73 |
return !$this->source;
|
74 |
}
|
|
|
75 |
public function isSeekable()
|
76 |
{
|
77 |
+
return \false;
|
78 |
}
|
|
|
79 |
public function rewind()
|
80 |
{
|
81 |
$this->seek(0);
|
82 |
}
|
83 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
84 |
{
|
85 |
throw new \RuntimeException('Cannot seek a PumpStream');
|
86 |
}
|
|
|
87 |
public function isWritable()
|
88 |
{
|
89 |
+
return \false;
|
90 |
}
|
|
|
91 |
public function write($string)
|
92 |
{
|
93 |
throw new \RuntimeException('Cannot write to a PumpStream');
|
94 |
}
|
|
|
95 |
public function isReadable()
|
96 |
{
|
97 |
+
return \true;
|
98 |
}
|
|
|
99 |
public function read($length)
|
100 |
{
|
101 |
$data = $this->buffer->read($length);
|
102 |
+
$readLen = \strlen($data);
|
103 |
$this->tellPos += $readLen;
|
104 |
$remaining = $length - $readLen;
|
|
|
105 |
if ($remaining) {
|
106 |
$this->pump($remaining);
|
107 |
$data .= $this->buffer->read($remaining);
|
108 |
+
$this->tellPos += \strlen($data) - $readLen;
|
109 |
}
|
|
|
110 |
return $data;
|
111 |
}
|
|
|
112 |
public function getContents()
|
113 |
{
|
114 |
$result = '';
|
115 |
while (!$this->eof()) {
|
116 |
$result .= $this->read(1000000);
|
117 |
}
|
|
|
118 |
return $result;
|
119 |
}
|
|
|
120 |
public function getMetadata($key = null)
|
121 |
{
|
122 |
if (!$key) {
|
123 |
return $this->metadata;
|
124 |
}
|
|
|
125 |
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
|
126 |
}
|
|
|
127 |
private function pump($length)
|
128 |
{
|
129 |
if ($this->source) {
|
130 |
do {
|
131 |
+
$data = \call_user_func($this->source, $length);
|
132 |
+
if ($data === \false || $data === null) {
|
133 |
$this->source = null;
|
134 |
return;
|
135 |
}
|
136 |
$this->buffer->write($data);
|
137 |
+
$length -= \strlen($data);
|
138 |
} while ($length > 0);
|
139 |
}
|
140 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Query.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Query
|
6 |
{
|
@@ -17,43 +17,40 @@ final class Query
|
|
17 |
*
|
18 |
* @return array
|
19 |
*/
|
20 |
-
public static function parse($str, $urlEncoding = true)
|
21 |
{
|
22 |
$result = [];
|
23 |
-
|
24 |
if ($str === '') {
|
25 |
return $result;
|
26 |
}
|
27 |
-
|
28 |
-
if ($urlEncoding === true) {
|
29 |
$decoder = function ($value) {
|
30 |
-
return rawurldecode(str_replace('+', ' ', $value));
|
31 |
};
|
32 |
-
} elseif ($urlEncoding === PHP_QUERY_RFC3986) {
|
33 |
$decoder = 'rawurldecode';
|
34 |
-
} elseif ($urlEncoding === PHP_QUERY_RFC1738) {
|
35 |
$decoder = 'urldecode';
|
36 |
} else {
|
37 |
-
$decoder = function ($str) {
|
|
|
|
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
$parts = explode('=', $kvp, 2);
|
42 |
$key = $decoder($parts[0]);
|
43 |
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
|
44 |
if (!isset($result[$key])) {
|
45 |
$result[$key] = $value;
|
46 |
} else {
|
47 |
-
if (
|
48 |
$result[$key] = [$result[$key]];
|
49 |
}
|
50 |
$result[$key][] = $value;
|
51 |
}
|
52 |
}
|
53 |
-
|
54 |
return $result;
|
55 |
}
|
56 |
-
|
57 |
/**
|
58 |
* Build a query string from an array of key value pairs.
|
59 |
*
|
@@ -67,26 +64,26 @@ final class Query
|
|
67 |
* to encode using RFC1738.
|
68 |
* @return string
|
69 |
*/
|
70 |
-
public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
|
71 |
{
|
72 |
if (!$params) {
|
73 |
return '';
|
74 |
}
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
$encoder = 'rawurlencode';
|
80 |
-
} elseif ($encoding === PHP_QUERY_RFC1738) {
|
81 |
$encoder = 'urlencode';
|
82 |
} else {
|
83 |
throw new \InvalidArgumentException('Invalid type');
|
84 |
}
|
85 |
-
|
86 |
$qs = '';
|
87 |
foreach ($params as $k => $v) {
|
88 |
$k = $encoder($k);
|
89 |
-
if (
|
90 |
$qs .= $k;
|
91 |
if ($v !== null) {
|
92 |
$qs .= '=' . $encoder($v);
|
@@ -102,7 +99,6 @@ final class Query
|
|
102 |
}
|
103 |
}
|
104 |
}
|
105 |
-
|
106 |
-
return $qs ? (string) substr($qs, 0, -1) : '';
|
107 |
}
|
108 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Query
|
6 |
{
|
17 |
*
|
18 |
* @return array
|
19 |
*/
|
20 |
+
public static function parse($str, $urlEncoding = \true)
|
21 |
{
|
22 |
$result = [];
|
|
|
23 |
if ($str === '') {
|
24 |
return $result;
|
25 |
}
|
26 |
+
if ($urlEncoding === \true) {
|
|
|
27 |
$decoder = function ($value) {
|
28 |
+
return \rawurldecode(\str_replace('+', ' ', $value));
|
29 |
};
|
30 |
+
} elseif ($urlEncoding === \PHP_QUERY_RFC3986) {
|
31 |
$decoder = 'rawurldecode';
|
32 |
+
} elseif ($urlEncoding === \PHP_QUERY_RFC1738) {
|
33 |
$decoder = 'urldecode';
|
34 |
} else {
|
35 |
+
$decoder = function ($str) {
|
36 |
+
return $str;
|
37 |
+
};
|
38 |
}
|
39 |
+
foreach (\explode('&', $str) as $kvp) {
|
40 |
+
$parts = \explode('=', $kvp, 2);
|
|
|
41 |
$key = $decoder($parts[0]);
|
42 |
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
|
43 |
if (!isset($result[$key])) {
|
44 |
$result[$key] = $value;
|
45 |
} else {
|
46 |
+
if (!\is_array($result[$key])) {
|
47 |
$result[$key] = [$result[$key]];
|
48 |
}
|
49 |
$result[$key][] = $value;
|
50 |
}
|
51 |
}
|
|
|
52 |
return $result;
|
53 |
}
|
|
|
54 |
/**
|
55 |
* Build a query string from an array of key value pairs.
|
56 |
*
|
64 |
* to encode using RFC1738.
|
65 |
* @return string
|
66 |
*/
|
67 |
+
public static function build(array $params, $encoding = \PHP_QUERY_RFC3986)
|
68 |
{
|
69 |
if (!$params) {
|
70 |
return '';
|
71 |
}
|
72 |
+
if ($encoding === \false) {
|
73 |
+
$encoder = function ($str) {
|
74 |
+
return $str;
|
75 |
+
};
|
76 |
+
} elseif ($encoding === \PHP_QUERY_RFC3986) {
|
77 |
$encoder = 'rawurlencode';
|
78 |
+
} elseif ($encoding === \PHP_QUERY_RFC1738) {
|
79 |
$encoder = 'urlencode';
|
80 |
} else {
|
81 |
throw new \InvalidArgumentException('Invalid type');
|
82 |
}
|
|
|
83 |
$qs = '';
|
84 |
foreach ($params as $k => $v) {
|
85 |
$k = $encoder($k);
|
86 |
+
if (!\is_array($v)) {
|
87 |
$qs .= $k;
|
88 |
if ($v !== null) {
|
89 |
$qs .= '=' . $encoder($v);
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
+
return $qs ? (string) \substr($qs, 0, -1) : '';
|
|
|
103 |
}
|
104 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Request.php
RENAMED
@@ -1,28 +1,23 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
-
use Psr\Http\Message\RequestInterface;
|
7 |
-
use Psr\Http\Message\StreamInterface;
|
8 |
-
use Psr\Http\Message\UriInterface;
|
9 |
-
|
10 |
/**
|
11 |
* PSR-7 request implementation.
|
12 |
*/
|
13 |
-
class Request implements RequestInterface
|
14 |
{
|
15 |
use MessageTrait;
|
16 |
-
|
17 |
/** @var string */
|
18 |
private $method;
|
19 |
-
|
20 |
/** @var null|string */
|
21 |
private $requestTarget;
|
22 |
-
|
23 |
/** @var UriInterface */
|
24 |
private $uri;
|
25 |
-
|
26 |
/**
|
27 |
* @param string $method HTTP method
|
28 |
* @param string|UriInterface $uri URI
|
@@ -30,38 +25,28 @@ class Request implements RequestInterface
|
|
30 |
* @param string|null|resource|StreamInterface $body Request body
|
31 |
* @param string $version Protocol version
|
32 |
*/
|
33 |
-
public function __construct(
|
34 |
-
|
35 |
-
$uri,
|
36 |
-
array $headers = [],
|
37 |
-
$body = null,
|
38 |
-
$version = '1.1'
|
39 |
-
) {
|
40 |
$this->assertMethod($method);
|
41 |
-
if (
|
42 |
-
$uri = new Uri($uri);
|
43 |
}
|
44 |
-
|
45 |
-
$this->method = strtoupper($method);
|
46 |
$this->uri = $uri;
|
47 |
$this->setHeaders($headers);
|
48 |
$this->protocol = $version;
|
49 |
-
|
50 |
if (!isset($this->headerNames['host'])) {
|
51 |
$this->updateHostFromUri();
|
52 |
}
|
53 |
-
|
54 |
if ($body !== '' && $body !== null) {
|
55 |
-
$this->stream = Utils::streamFor($body);
|
56 |
}
|
57 |
}
|
58 |
-
|
59 |
public function getRequestTarget()
|
60 |
{
|
61 |
if ($this->requestTarget !== null) {
|
62 |
return $this->requestTarget;
|
63 |
}
|
64 |
-
|
65 |
$target = $this->uri->getPath();
|
66 |
if ($target == '') {
|
67 |
$target = '/';
|
@@ -69,69 +54,53 @@ class Request implements RequestInterface
|
|
69 |
if ($this->uri->getQuery() != '') {
|
70 |
$target .= '?' . $this->uri->getQuery();
|
71 |
}
|
72 |
-
|
73 |
return $target;
|
74 |
}
|
75 |
-
|
76 |
public function withRequestTarget($requestTarget)
|
77 |
{
|
78 |
-
if (preg_match('
|
79 |
-
throw new InvalidArgumentException(
|
80 |
-
'Invalid request target provided; cannot contain whitespace'
|
81 |
-
);
|
82 |
}
|
83 |
-
|
84 |
$new = clone $this;
|
85 |
$new->requestTarget = $requestTarget;
|
86 |
return $new;
|
87 |
}
|
88 |
-
|
89 |
public function getMethod()
|
90 |
{
|
91 |
return $this->method;
|
92 |
}
|
93 |
-
|
94 |
public function withMethod($method)
|
95 |
{
|
96 |
$this->assertMethod($method);
|
97 |
$new = clone $this;
|
98 |
-
$new->method = strtoupper($method);
|
99 |
return $new;
|
100 |
}
|
101 |
-
|
102 |
public function getUri()
|
103 |
{
|
104 |
return $this->uri;
|
105 |
}
|
106 |
-
|
107 |
-
public function withUri(UriInterface $uri, $preserveHost = false)
|
108 |
{
|
109 |
if ($uri === $this->uri) {
|
110 |
return $this;
|
111 |
}
|
112 |
-
|
113 |
$new = clone $this;
|
114 |
$new->uri = $uri;
|
115 |
-
|
116 |
if (!$preserveHost || !isset($this->headerNames['host'])) {
|
117 |
$new->updateHostFromUri();
|
118 |
}
|
119 |
-
|
120 |
return $new;
|
121 |
}
|
122 |
-
|
123 |
private function updateHostFromUri()
|
124 |
{
|
125 |
$host = $this->uri->getHost();
|
126 |
-
|
127 |
if ($host == '') {
|
128 |
return;
|
129 |
}
|
130 |
-
|
131 |
if (($port = $this->uri->getPort()) !== null) {
|
132 |
$host .= ':' . $port;
|
133 |
}
|
134 |
-
|
135 |
if (isset($this->headerNames['host'])) {
|
136 |
$header = $this->headerNames['host'];
|
137 |
} else {
|
@@ -142,10 +111,9 @@ class Request implements RequestInterface
|
|
142 |
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
143 |
$this->headers = [$header => [$host]] + $this->headers;
|
144 |
}
|
145 |
-
|
146 |
private function assertMethod($method)
|
147 |
{
|
148 |
-
if (
|
149 |
throw new \InvalidArgumentException('Method must be a non-empty string.');
|
150 |
}
|
151 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
|
|
9 |
/**
|
10 |
* PSR-7 request implementation.
|
11 |
*/
|
12 |
+
class Request implements \PixelCaffeine\Dependencies\Psr\Http\Message\RequestInterface
|
13 |
{
|
14 |
use MessageTrait;
|
|
|
15 |
/** @var string */
|
16 |
private $method;
|
|
|
17 |
/** @var null|string */
|
18 |
private $requestTarget;
|
|
|
19 |
/** @var UriInterface */
|
20 |
private $uri;
|
|
|
21 |
/**
|
22 |
* @param string $method HTTP method
|
23 |
* @param string|UriInterface $uri URI
|
25 |
* @param string|null|resource|StreamInterface $body Request body
|
26 |
* @param string $version Protocol version
|
27 |
*/
|
28 |
+
public function __construct($method, $uri, array $headers = [], $body = null, $version = '1.1')
|
29 |
+
{
|
|
|
|
|
|
|
|
|
|
|
30 |
$this->assertMethod($method);
|
31 |
+
if (!$uri instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface) {
|
32 |
+
$uri = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Uri($uri);
|
33 |
}
|
34 |
+
$this->method = \strtoupper($method);
|
|
|
35 |
$this->uri = $uri;
|
36 |
$this->setHeaders($headers);
|
37 |
$this->protocol = $version;
|
|
|
38 |
if (!isset($this->headerNames['host'])) {
|
39 |
$this->updateHostFromUri();
|
40 |
}
|
|
|
41 |
if ($body !== '' && $body !== null) {
|
42 |
+
$this->stream = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor($body);
|
43 |
}
|
44 |
}
|
|
|
45 |
public function getRequestTarget()
|
46 |
{
|
47 |
if ($this->requestTarget !== null) {
|
48 |
return $this->requestTarget;
|
49 |
}
|
|
|
50 |
$target = $this->uri->getPath();
|
51 |
if ($target == '') {
|
52 |
$target = '/';
|
54 |
if ($this->uri->getQuery() != '') {
|
55 |
$target .= '?' . $this->uri->getQuery();
|
56 |
}
|
|
|
57 |
return $target;
|
58 |
}
|
|
|
59 |
public function withRequestTarget($requestTarget)
|
60 |
{
|
61 |
+
if (\preg_match('#\\s#', $requestTarget)) {
|
62 |
+
throw new \InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
|
|
|
|
|
63 |
}
|
|
|
64 |
$new = clone $this;
|
65 |
$new->requestTarget = $requestTarget;
|
66 |
return $new;
|
67 |
}
|
|
|
68 |
public function getMethod()
|
69 |
{
|
70 |
return $this->method;
|
71 |
}
|
|
|
72 |
public function withMethod($method)
|
73 |
{
|
74 |
$this->assertMethod($method);
|
75 |
$new = clone $this;
|
76 |
+
$new->method = \strtoupper($method);
|
77 |
return $new;
|
78 |
}
|
|
|
79 |
public function getUri()
|
80 |
{
|
81 |
return $this->uri;
|
82 |
}
|
83 |
+
public function withUri(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, $preserveHost = \false)
|
|
|
84 |
{
|
85 |
if ($uri === $this->uri) {
|
86 |
return $this;
|
87 |
}
|
|
|
88 |
$new = clone $this;
|
89 |
$new->uri = $uri;
|
|
|
90 |
if (!$preserveHost || !isset($this->headerNames['host'])) {
|
91 |
$new->updateHostFromUri();
|
92 |
}
|
|
|
93 |
return $new;
|
94 |
}
|
|
|
95 |
private function updateHostFromUri()
|
96 |
{
|
97 |
$host = $this->uri->getHost();
|
|
|
98 |
if ($host == '') {
|
99 |
return;
|
100 |
}
|
|
|
101 |
if (($port = $this->uri->getPort()) !== null) {
|
102 |
$host .= ':' . $port;
|
103 |
}
|
|
|
104 |
if (isset($this->headerNames['host'])) {
|
105 |
$header = $this->headerNames['host'];
|
106 |
} else {
|
111 |
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
112 |
$this->headers = [$header => [$host]] + $this->headers;
|
113 |
}
|
|
|
114 |
private function assertMethod($method)
|
115 |
{
|
116 |
+
if (!\is_string($method) || $method === '') {
|
117 |
throw new \InvalidArgumentException('Method must be a non-empty string.');
|
118 |
}
|
119 |
}
|
third-party/vendor/guzzlehttp/psr7/src/Response.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
+
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
7 |
+
/**
|
8 |
+
* PSR-7 response implementation.
|
9 |
+
*/
|
10 |
+
class Response implements \PixelCaffeine\Dependencies\Psr\Http\Message\ResponseInterface
|
11 |
+
{
|
12 |
+
use MessageTrait;
|
13 |
+
/** @var array Map of standard HTTP status code/reason phrases */
|
14 |
+
private static $phrases = [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 511 => 'Network Authentication Required'];
|
15 |
+
/** @var string */
|
16 |
+
private $reasonPhrase = '';
|
17 |
+
/** @var int */
|
18 |
+
private $statusCode = 200;
|
19 |
+
/**
|
20 |
+
* @param int $status Status code
|
21 |
+
* @param array $headers Response headers
|
22 |
+
* @param string|null|resource|StreamInterface $body Response body
|
23 |
+
* @param string $version Protocol version
|
24 |
+
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
25 |
+
*/
|
26 |
+
public function __construct($status = 200, array $headers = [], $body = null, $version = '1.1', $reason = null)
|
27 |
+
{
|
28 |
+
$this->assertStatusCodeIsInteger($status);
|
29 |
+
$status = (int) $status;
|
30 |
+
$this->assertStatusCodeRange($status);
|
31 |
+
$this->statusCode = $status;
|
32 |
+
if ($body !== '' && $body !== null) {
|
33 |
+
$this->stream = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::streamFor($body);
|
34 |
+
}
|
35 |
+
$this->setHeaders($headers);
|
36 |
+
if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
|
37 |
+
$this->reasonPhrase = self::$phrases[$this->statusCode];
|
38 |
+
} else {
|
39 |
+
$this->reasonPhrase = (string) $reason;
|
40 |
+
}
|
41 |
+
$this->protocol = $version;
|
42 |
+
}
|
43 |
+
public function getStatusCode()
|
44 |
+
{
|
45 |
+
return $this->statusCode;
|
46 |
+
}
|
47 |
+
public function getReasonPhrase()
|
48 |
+
{
|
49 |
+
return $this->reasonPhrase;
|
50 |
+
}
|
51 |
+
public function withStatus($code, $reasonPhrase = '')
|
52 |
+
{
|
53 |
+
$this->assertStatusCodeIsInteger($code);
|
54 |
+
$code = (int) $code;
|
55 |
+
$this->assertStatusCodeRange($code);
|
56 |
+
$new = clone $this;
|
57 |
+
$new->statusCode = $code;
|
58 |
+
if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
|
59 |
+
$reasonPhrase = self::$phrases[$new->statusCode];
|
60 |
+
}
|
61 |
+
$new->reasonPhrase = (string) $reasonPhrase;
|
62 |
+
return $new;
|
63 |
+
}
|
64 |
+
private function assertStatusCodeIsInteger($statusCode)
|
65 |
+
{
|
66 |
+
if (\filter_var($statusCode, \FILTER_VALIDATE_INT) === \false) {
|
67 |
+
throw new \InvalidArgumentException('Status code must be an integer value.');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
private function assertStatusCodeRange($statusCode)
|
71 |
+
{
|
72 |
+
if ($statusCode < 100 || $statusCode >= 600) {
|
73 |
+
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Rfc7230.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Rfc7230
|
6 |
{
|
@@ -13,6 +13,6 @@ final class Rfc7230
|
|
13 |
* @link https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
|
14 |
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
|
15 |
*/
|
16 |
-
const HEADER_REGEX = "(^([^()<>@,;:\\\"/[
|
17 |
const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
18 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
final class Rfc7230
|
6 |
{
|
13 |
* @link https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
|
14 |
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
|
15 |
*/
|
16 |
+
const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\\]?={}\1- ]++):[ \t]*+((?:[ \t]*+[!-~�-�]++)*+)[ \t]*+\r?\n)m";
|
17 |
const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
18 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/ServerRequest.php
RENAMED
@@ -1,13 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
-
use Psr\Http\Message\ServerRequestInterface;
|
7 |
-
use Psr\Http\Message\UriInterface;
|
8 |
-
use Psr\Http\Message\StreamInterface;
|
9 |
-
use Psr\Http\Message\UploadedFileInterface;
|
10 |
-
|
11 |
/**
|
12 |
* Server-side HTTP request
|
13 |
*
|
@@ -22,38 +21,32 @@ use Psr\Http\Message\UploadedFileInterface;
|
|
22 |
* implemented such that they retain the internal state of the current
|
23 |
* message and return a new instance that contains the changed state.
|
24 |
*/
|
25 |
-
class ServerRequest extends Request implements ServerRequestInterface
|
26 |
{
|
27 |
/**
|
28 |
* @var array
|
29 |
*/
|
30 |
private $attributes = [];
|
31 |
-
|
32 |
/**
|
33 |
* @var array
|
34 |
*/
|
35 |
private $cookieParams = [];
|
36 |
-
|
37 |
/**
|
38 |
* @var null|array|object
|
39 |
*/
|
40 |
private $parsedBody;
|
41 |
-
|
42 |
/**
|
43 |
* @var array
|
44 |
*/
|
45 |
private $queryParams = [];
|
46 |
-
|
47 |
/**
|
48 |
* @var array
|
49 |
*/
|
50 |
private $serverParams;
|
51 |
-
|
52 |
/**
|
53 |
* @var array
|
54 |
*/
|
55 |
private $uploadedFiles = [];
|
56 |
-
|
57 |
/**
|
58 |
* @param string $method HTTP method
|
59 |
* @param string|UriInterface $uri URI
|
@@ -62,19 +55,11 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
62 |
* @param string $version Protocol version
|
63 |
* @param array $serverParams Typically the $_SERVER superglobal
|
64 |
*/
|
65 |
-
public function __construct(
|
66 |
-
|
67 |
-
$uri,
|
68 |
-
array $headers = [],
|
69 |
-
$body = null,
|
70 |
-
$version = '1.1',
|
71 |
-
array $serverParams = []
|
72 |
-
) {
|
73 |
$this->serverParams = $serverParams;
|
74 |
-
|
75 |
parent::__construct($method, $uri, $headers, $body, $version);
|
76 |
}
|
77 |
-
|
78 |
/**
|
79 |
* Return an UploadedFile instance array.
|
80 |
*
|
@@ -87,23 +72,20 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
87 |
public static function normalizeFiles(array $files)
|
88 |
{
|
89 |
$normalized = [];
|
90 |
-
|
91 |
foreach ($files as $key => $value) {
|
92 |
-
if ($value instanceof UploadedFileInterface) {
|
93 |
$normalized[$key] = $value;
|
94 |
-
} elseif (is_array($value) && isset($value['tmp_name'])) {
|
95 |
$normalized[$key] = self::createUploadedFileFromSpec($value);
|
96 |
-
} elseif (is_array($value)) {
|
97 |
$normalized[$key] = self::normalizeFiles($value);
|
98 |
continue;
|
99 |
} else {
|
100 |
-
throw new InvalidArgumentException('Invalid value in files specification');
|
101 |
}
|
102 |
}
|
103 |
-
|
104 |
return $normalized;
|
105 |
}
|
106 |
-
|
107 |
/**
|
108 |
* Create and return an UploadedFile instance from a $_FILES specification.
|
109 |
*
|
@@ -115,19 +97,11 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
115 |
*/
|
116 |
private static function createUploadedFileFromSpec(array $value)
|
117 |
{
|
118 |
-
if (is_array($value['tmp_name'])) {
|
119 |
return self::normalizeNestedFileSpec($value);
|
120 |
}
|
121 |
-
|
122 |
-
return new UploadedFile(
|
123 |
-
$value['tmp_name'],
|
124 |
-
(int) $value['size'],
|
125 |
-
(int) $value['error'],
|
126 |
-
$value['name'],
|
127 |
-
$value['type']
|
128 |
-
);
|
129 |
}
|
130 |
-
|
131 |
/**
|
132 |
* Normalize an array of file specifications.
|
133 |
*
|
@@ -140,21 +114,12 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
140 |
private static function normalizeNestedFileSpec(array $files = [])
|
141 |
{
|
142 |
$normalizedFiles = [];
|
143 |
-
|
144 |
-
|
145 |
-
$spec = [
|
146 |
-
'tmp_name' => $files['tmp_name'][$key],
|
147 |
-
'size' => $files['size'][$key],
|
148 |
-
'error' => $files['error'][$key],
|
149 |
-
'name' => $files['name'][$key],
|
150 |
-
'type' => $files['type'][$key],
|
151 |
-
];
|
152 |
$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
|
153 |
}
|
154 |
-
|
155 |
return $normalizedFiles;
|
156 |
}
|
157 |
-
|
158 |
/**
|
159 |
* Return a ServerRequest populated with superglobals:
|
160 |
* $_GET
|
@@ -168,34 +133,24 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
168 |
public static function fromGlobals()
|
169 |
{
|
170 |
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
171 |
-
$headers = getallheaders();
|
172 |
$uri = self::getUriFromGlobals();
|
173 |
-
$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
|
174 |
-
$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
|
175 |
-
|
176 |
-
$serverRequest
|
177 |
-
|
178 |
-
return $serverRequest
|
179 |
-
->withCookieParams($_COOKIE)
|
180 |
-
->withQueryParams($_GET)
|
181 |
-
->withParsedBody($_POST)
|
182 |
-
->withUploadedFiles(self::normalizeFiles($_FILES));
|
183 |
}
|
184 |
-
|
185 |
private static function extractHostAndPortFromAuthority($authority)
|
186 |
{
|
187 |
-
$uri = 'http://'
|
188 |
-
$parts = parse_url($uri);
|
189 |
-
if (false === $parts) {
|
190 |
return [null, null];
|
191 |
}
|
192 |
-
|
193 |
$host = isset($parts['host']) ? $parts['host'] : null;
|
194 |
$port = isset($parts['port']) ? $parts['port'] : null;
|
195 |
-
|
196 |
return [$host, $port];
|
197 |
}
|
198 |
-
|
199 |
/**
|
200 |
* Get a Uri populated with values from $_SERVER.
|
201 |
*
|
@@ -203,19 +158,16 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
203 |
*/
|
204 |
public static function getUriFromGlobals()
|
205 |
{
|
206 |
-
$uri = new Uri('');
|
207 |
-
|
208 |
$uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
|
209 |
-
|
210 |
-
$hasPort = false;
|
211 |
if (isset($_SERVER['HTTP_HOST'])) {
|
212 |
list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
213 |
if ($host !== null) {
|
214 |
$uri = $uri->withHost($host);
|
215 |
}
|
216 |
-
|
217 |
if ($port !== null) {
|
218 |
-
$hasPort = true;
|
219 |
$uri = $uri->withPort($port);
|
220 |
}
|
221 |
} elseif (isset($_SERVER['SERVER_NAME'])) {
|
@@ -223,29 +175,23 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
223 |
} elseif (isset($_SERVER['SERVER_ADDR'])) {
|
224 |
$uri = $uri->withHost($_SERVER['SERVER_ADDR']);
|
225 |
}
|
226 |
-
|
227 |
if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
|
228 |
$uri = $uri->withPort($_SERVER['SERVER_PORT']);
|
229 |
}
|
230 |
-
|
231 |
-
$hasQuery = false;
|
232 |
if (isset($_SERVER['REQUEST_URI'])) {
|
233 |
-
$requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
|
234 |
$uri = $uri->withPath($requestUriParts[0]);
|
235 |
if (isset($requestUriParts[1])) {
|
236 |
-
$hasQuery = true;
|
237 |
$uri = $uri->withQuery($requestUriParts[1]);
|
238 |
}
|
239 |
}
|
240 |
-
|
241 |
if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
|
242 |
$uri = $uri->withQuery($_SERVER['QUERY_STRING']);
|
243 |
}
|
244 |
-
|
245 |
return $uri;
|
246 |
}
|
247 |
-
|
248 |
-
|
249 |
/**
|
250 |
* {@inheritdoc}
|
251 |
*/
|
@@ -253,7 +199,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
253 |
{
|
254 |
return $this->serverParams;
|
255 |
}
|
256 |
-
|
257 |
/**
|
258 |
* {@inheritdoc}
|
259 |
*/
|
@@ -261,7 +206,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
261 |
{
|
262 |
return $this->uploadedFiles;
|
263 |
}
|
264 |
-
|
265 |
/**
|
266 |
* {@inheritdoc}
|
267 |
*/
|
@@ -269,10 +213,8 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
269 |
{
|
270 |
$new = clone $this;
|
271 |
$new->uploadedFiles = $uploadedFiles;
|
272 |
-
|
273 |
return $new;
|
274 |
}
|
275 |
-
|
276 |
/**
|
277 |
* {@inheritdoc}
|
278 |
*/
|
@@ -280,7 +222,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
280 |
{
|
281 |
return $this->cookieParams;
|
282 |
}
|
283 |
-
|
284 |
/**
|
285 |
* {@inheritdoc}
|
286 |
*/
|
@@ -288,10 +229,8 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
288 |
{
|
289 |
$new = clone $this;
|
290 |
$new->cookieParams = $cookies;
|
291 |
-
|
292 |
return $new;
|
293 |
}
|
294 |
-
|
295 |
/**
|
296 |
* {@inheritdoc}
|
297 |
*/
|
@@ -299,7 +238,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
299 |
{
|
300 |
return $this->queryParams;
|
301 |
}
|
302 |
-
|
303 |
/**
|
304 |
* {@inheritdoc}
|
305 |
*/
|
@@ -307,10 +245,8 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
307 |
{
|
308 |
$new = clone $this;
|
309 |
$new->queryParams = $query;
|
310 |
-
|
311 |
return $new;
|
312 |
}
|
313 |
-
|
314 |
/**
|
315 |
* {@inheritdoc}
|
316 |
*/
|
@@ -318,7 +254,6 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
318 |
{
|
319 |
return $this->parsedBody;
|
320 |
}
|
321 |
-
|
322 |
/**
|
323 |
* {@inheritdoc}
|
324 |
*/
|
@@ -326,10 +261,8 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
326 |
{
|
327 |
$new = clone $this;
|
328 |
$new->parsedBody = $data;
|
329 |
-
|
330 |
return $new;
|
331 |
}
|
332 |
-
|
333 |
/**
|
334 |
* {@inheritdoc}
|
335 |
*/
|
@@ -337,19 +270,16 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
337 |
{
|
338 |
return $this->attributes;
|
339 |
}
|
340 |
-
|
341 |
/**
|
342 |
* {@inheritdoc}
|
343 |
*/
|
344 |
public function getAttribute($attribute, $default = null)
|
345 |
{
|
346 |
-
if (false === array_key_exists($attribute, $this->attributes)) {
|
347 |
return $default;
|
348 |
}
|
349 |
-
|
350 |
return $this->attributes[$attribute];
|
351 |
}
|
352 |
-
|
353 |
/**
|
354 |
* {@inheritdoc}
|
355 |
*/
|
@@ -357,22 +287,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
|
357 |
{
|
358 |
$new = clone $this;
|
359 |
$new->attributes[$attribute] = $value;
|
360 |
-
|
361 |
return $new;
|
362 |
}
|
363 |
-
|
364 |
/**
|
365 |
* {@inheritdoc}
|
366 |
*/
|
367 |
public function withoutAttribute($attribute)
|
368 |
{
|
369 |
-
if (false === array_key_exists($attribute, $this->attributes)) {
|
370 |
return $this;
|
371 |
}
|
372 |
-
|
373 |
$new = clone $this;
|
374 |
unset($new->attributes[$attribute]);
|
375 |
-
|
376 |
return $new;
|
377 |
}
|
378 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\ServerRequestInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
8 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
9 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UploadedFileInterface;
|
|
|
10 |
/**
|
11 |
* Server-side HTTP request
|
12 |
*
|
21 |
* implemented such that they retain the internal state of the current
|
22 |
* message and return a new instance that contains the changed state.
|
23 |
*/
|
24 |
+
class ServerRequest extends \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Request implements \PixelCaffeine\Dependencies\Psr\Http\Message\ServerRequestInterface
|
25 |
{
|
26 |
/**
|
27 |
* @var array
|
28 |
*/
|
29 |
private $attributes = [];
|
|
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
private $cookieParams = [];
|
|
|
34 |
/**
|
35 |
* @var null|array|object
|
36 |
*/
|
37 |
private $parsedBody;
|
|
|
38 |
/**
|
39 |
* @var array
|
40 |
*/
|
41 |
private $queryParams = [];
|
|
|
42 |
/**
|
43 |
* @var array
|
44 |
*/
|
45 |
private $serverParams;
|
|
|
46 |
/**
|
47 |
* @var array
|
48 |
*/
|
49 |
private $uploadedFiles = [];
|
|
|
50 |
/**
|
51 |
* @param string $method HTTP method
|
52 |
* @param string|UriInterface $uri URI
|
55 |
* @param string $version Protocol version
|
56 |
* @param array $serverParams Typically the $_SERVER superglobal
|
57 |
*/
|
58 |
+
public function __construct($method, $uri, array $headers = [], $body = null, $version = '1.1', array $serverParams = [])
|
59 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
$this->serverParams = $serverParams;
|
|
|
61 |
parent::__construct($method, $uri, $headers, $body, $version);
|
62 |
}
|
|
|
63 |
/**
|
64 |
* Return an UploadedFile instance array.
|
65 |
*
|
72 |
public static function normalizeFiles(array $files)
|
73 |
{
|
74 |
$normalized = [];
|
|
|
75 |
foreach ($files as $key => $value) {
|
76 |
+
if ($value instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\UploadedFileInterface) {
|
77 |
$normalized[$key] = $value;
|
78 |
+
} elseif (\is_array($value) && isset($value['tmp_name'])) {
|
79 |
$normalized[$key] = self::createUploadedFileFromSpec($value);
|
80 |
+
} elseif (\is_array($value)) {
|
81 |
$normalized[$key] = self::normalizeFiles($value);
|
82 |
continue;
|
83 |
} else {
|
84 |
+
throw new \InvalidArgumentException('Invalid value in files specification');
|
85 |
}
|
86 |
}
|
|
|
87 |
return $normalized;
|
88 |
}
|
|
|
89 |
/**
|
90 |
* Create and return an UploadedFile instance from a $_FILES specification.
|
91 |
*
|
97 |
*/
|
98 |
private static function createUploadedFileFromSpec(array $value)
|
99 |
{
|
100 |
+
if (\is_array($value['tmp_name'])) {
|
101 |
return self::normalizeNestedFileSpec($value);
|
102 |
}
|
103 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
|
|
105 |
/**
|
106 |
* Normalize an array of file specifications.
|
107 |
*
|
114 |
private static function normalizeNestedFileSpec(array $files = [])
|
115 |
{
|
116 |
$normalizedFiles = [];
|
117 |
+
foreach (\array_keys($files['tmp_name']) as $key) {
|
118 |
+
$spec = ['tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key], 'error' => $files['error'][$key], 'name' => $files['name'][$key], 'type' => $files['type'][$key]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
|
120 |
}
|
|
|
121 |
return $normalizedFiles;
|
122 |
}
|
|
|
123 |
/**
|
124 |
* Return a ServerRequest populated with superglobals:
|
125 |
* $_GET
|
133 |
public static function fromGlobals()
|
134 |
{
|
135 |
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
136 |
+
$headers = \getallheaders();
|
137 |
$uri = self::getUriFromGlobals();
|
138 |
+
$body = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\CachingStream(new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream('php://input', 'r+'));
|
139 |
+
$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
|
140 |
+
$serverRequest = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
|
141 |
+
return $serverRequest->withCookieParams($_COOKIE)->withQueryParams($_GET)->withParsedBody($_POST)->withUploadedFiles(self::normalizeFiles($_FILES));
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
143 |
private static function extractHostAndPortFromAuthority($authority)
|
144 |
{
|
145 |
+
$uri = 'http://' . $authority;
|
146 |
+
$parts = \parse_url($uri);
|
147 |
+
if (\false === $parts) {
|
148 |
return [null, null];
|
149 |
}
|
|
|
150 |
$host = isset($parts['host']) ? $parts['host'] : null;
|
151 |
$port = isset($parts['port']) ? $parts['port'] : null;
|
|
|
152 |
return [$host, $port];
|
153 |
}
|
|
|
154 |
/**
|
155 |
* Get a Uri populated with values from $_SERVER.
|
156 |
*
|
158 |
*/
|
159 |
public static function getUriFromGlobals()
|
160 |
{
|
161 |
+
$uri = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Uri('');
|
|
|
162 |
$uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
|
163 |
+
$hasPort = \false;
|
|
|
164 |
if (isset($_SERVER['HTTP_HOST'])) {
|
165 |
list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
166 |
if ($host !== null) {
|
167 |
$uri = $uri->withHost($host);
|
168 |
}
|
|
|
169 |
if ($port !== null) {
|
170 |
+
$hasPort = \true;
|
171 |
$uri = $uri->withPort($port);
|
172 |
}
|
173 |
} elseif (isset($_SERVER['SERVER_NAME'])) {
|
175 |
} elseif (isset($_SERVER['SERVER_ADDR'])) {
|
176 |
$uri = $uri->withHost($_SERVER['SERVER_ADDR']);
|
177 |
}
|
|
|
178 |
if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
|
179 |
$uri = $uri->withPort($_SERVER['SERVER_PORT']);
|
180 |
}
|
181 |
+
$hasQuery = \false;
|
|
|
182 |
if (isset($_SERVER['REQUEST_URI'])) {
|
183 |
+
$requestUriParts = \explode('?', $_SERVER['REQUEST_URI'], 2);
|
184 |
$uri = $uri->withPath($requestUriParts[0]);
|
185 |
if (isset($requestUriParts[1])) {
|
186 |
+
$hasQuery = \true;
|
187 |
$uri = $uri->withQuery($requestUriParts[1]);
|
188 |
}
|
189 |
}
|
|
|
190 |
if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
|
191 |
$uri = $uri->withQuery($_SERVER['QUERY_STRING']);
|
192 |
}
|
|
|
193 |
return $uri;
|
194 |
}
|
|
|
|
|
195 |
/**
|
196 |
* {@inheritdoc}
|
197 |
*/
|
199 |
{
|
200 |
return $this->serverParams;
|
201 |
}
|
|
|
202 |
/**
|
203 |
* {@inheritdoc}
|
204 |
*/
|
206 |
{
|
207 |
return $this->uploadedFiles;
|
208 |
}
|
|
|
209 |
/**
|
210 |
* {@inheritdoc}
|
211 |
*/
|
213 |
{
|
214 |
$new = clone $this;
|
215 |
$new->uploadedFiles = $uploadedFiles;
|
|
|
216 |
return $new;
|
217 |
}
|
|
|
218 |
/**
|
219 |
* {@inheritdoc}
|
220 |
*/
|
222 |
{
|
223 |
return $this->cookieParams;
|
224 |
}
|
|
|
225 |
/**
|
226 |
* {@inheritdoc}
|
227 |
*/
|
229 |
{
|
230 |
$new = clone $this;
|
231 |
$new->cookieParams = $cookies;
|
|
|
232 |
return $new;
|
233 |
}
|
|
|
234 |
/**
|
235 |
* {@inheritdoc}
|
236 |
*/
|
238 |
{
|
239 |
return $this->queryParams;
|
240 |
}
|
|
|
241 |
/**
|
242 |
* {@inheritdoc}
|
243 |
*/
|
245 |
{
|
246 |
$new = clone $this;
|
247 |
$new->queryParams = $query;
|
|
|
248 |
return $new;
|
249 |
}
|
|
|
250 |
/**
|
251 |
* {@inheritdoc}
|
252 |
*/
|
254 |
{
|
255 |
return $this->parsedBody;
|
256 |
}
|
|
|
257 |
/**
|
258 |
* {@inheritdoc}
|
259 |
*/
|
261 |
{
|
262 |
$new = clone $this;
|
263 |
$new->parsedBody = $data;
|
|
|
264 |
return $new;
|
265 |
}
|
|
|
266 |
/**
|
267 |
* {@inheritdoc}
|
268 |
*/
|
270 |
{
|
271 |
return $this->attributes;
|
272 |
}
|
|
|
273 |
/**
|
274 |
* {@inheritdoc}
|
275 |
*/
|
276 |
public function getAttribute($attribute, $default = null)
|
277 |
{
|
278 |
+
if (\false === \array_key_exists($attribute, $this->attributes)) {
|
279 |
return $default;
|
280 |
}
|
|
|
281 |
return $this->attributes[$attribute];
|
282 |
}
|
|
|
283 |
/**
|
284 |
* {@inheritdoc}
|
285 |
*/
|
287 |
{
|
288 |
$new = clone $this;
|
289 |
$new->attributes[$attribute] = $value;
|
|
|
290 |
return $new;
|
291 |
}
|
|
|
292 |
/**
|
293 |
* {@inheritdoc}
|
294 |
*/
|
295 |
public function withoutAttribute($attribute)
|
296 |
{
|
297 |
+
if (\false === \array_key_exists($attribute, $this->attributes)) {
|
298 |
return $this;
|
299 |
}
|
|
|
300 |
$new = clone $this;
|
301 |
unset($new->attributes[$attribute]);
|
|
|
302 |
return $new;
|
303 |
}
|
304 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Stream.php
RENAMED
@@ -1,15 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* PHP stream implementation.
|
9 |
*
|
10 |
* @var $stream
|
11 |
*/
|
12 |
-
class Stream implements StreamInterface
|
13 |
{
|
14 |
/**
|
15 |
* Resource modes.
|
@@ -19,9 +18,8 @@ class Stream implements StreamInterface
|
|
19 |
* @see http://php.net/manual/function.fopen.php
|
20 |
* @see http://php.net/manual/en/function.gzopen.php
|
21 |
*/
|
22 |
-
const READABLE_MODES = '/r|a
|
23 |
-
const WRITABLE_MODES = '/a|w|r
|
24 |
-
|
25 |
private $stream;
|
26 |
private $size;
|
27 |
private $seekable;
|
@@ -29,7 +27,6 @@ class Stream implements StreamInterface
|
|
29 |
private $writable;
|
30 |
private $uri;
|
31 |
private $customMetadata;
|
32 |
-
|
33 |
/**
|
34 |
* This constructor accepts an associative array of options.
|
35 |
*
|
@@ -46,26 +43,20 @@ class Stream implements StreamInterface
|
|
46 |
*/
|
47 |
public function __construct($stream, $options = [])
|
48 |
{
|
49 |
-
if (
|
50 |
throw new \InvalidArgumentException('Stream must be a resource');
|
51 |
}
|
52 |
-
|
53 |
if (isset($options['size'])) {
|
54 |
$this->size = $options['size'];
|
55 |
}
|
56 |
-
|
57 |
-
$this->customMetadata = isset($options['metadata'])
|
58 |
-
? $options['metadata']
|
59 |
-
: [];
|
60 |
-
|
61 |
$this->stream = $stream;
|
62 |
-
$meta = stream_get_meta_data($this->stream);
|
63 |
$this->seekable = $meta['seekable'];
|
64 |
-
$this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
|
65 |
-
$this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
|
66 |
$this->uri = $this->getMetadata('uri');
|
67 |
}
|
68 |
-
|
69 |
/**
|
70 |
* Closes the stream when the destructed
|
71 |
*/
|
@@ -73,7 +64,6 @@ class Stream implements StreamInterface
|
|
73 |
{
|
74 |
$this->close();
|
75 |
}
|
76 |
-
|
77 |
public function __toString()
|
78 |
{
|
79 |
try {
|
@@ -85,130 +75,103 @@ class Stream implements StreamInterface
|
|
85 |
return '';
|
86 |
}
|
87 |
}
|
88 |
-
|
89 |
public function getContents()
|
90 |
{
|
91 |
if (!isset($this->stream)) {
|
92 |
throw new \RuntimeException('Stream is detached');
|
93 |
}
|
94 |
-
|
95 |
-
$contents
|
96 |
-
|
97 |
-
if ($contents === false) {
|
98 |
throw new \RuntimeException('Unable to read stream contents');
|
99 |
}
|
100 |
-
|
101 |
return $contents;
|
102 |
}
|
103 |
-
|
104 |
public function close()
|
105 |
{
|
106 |
if (isset($this->stream)) {
|
107 |
-
if (is_resource($this->stream)) {
|
108 |
-
fclose($this->stream);
|
109 |
}
|
110 |
$this->detach();
|
111 |
}
|
112 |
}
|
113 |
-
|
114 |
public function detach()
|
115 |
{
|
116 |
if (!isset($this->stream)) {
|
117 |
return null;
|
118 |
}
|
119 |
-
|
120 |
$result = $this->stream;
|
121 |
unset($this->stream);
|
122 |
$this->size = $this->uri = null;
|
123 |
-
$this->readable = $this->writable = $this->seekable = false;
|
124 |
-
|
125 |
return $result;
|
126 |
}
|
127 |
-
|
128 |
public function getSize()
|
129 |
{
|
130 |
if ($this->size !== null) {
|
131 |
return $this->size;
|
132 |
}
|
133 |
-
|
134 |
if (!isset($this->stream)) {
|
135 |
return null;
|
136 |
}
|
137 |
-
|
138 |
// Clear the stat cache if the stream has a URI
|
139 |
if ($this->uri) {
|
140 |
-
clearstatcache(true, $this->uri);
|
141 |
}
|
142 |
-
|
143 |
-
$stats = fstat($this->stream);
|
144 |
if (isset($stats['size'])) {
|
145 |
$this->size = $stats['size'];
|
146 |
return $this->size;
|
147 |
}
|
148 |
-
|
149 |
return null;
|
150 |
}
|
151 |
-
|
152 |
public function isReadable()
|
153 |
{
|
154 |
return $this->readable;
|
155 |
}
|
156 |
-
|
157 |
public function isWritable()
|
158 |
{
|
159 |
return $this->writable;
|
160 |
}
|
161 |
-
|
162 |
public function isSeekable()
|
163 |
{
|
164 |
return $this->seekable;
|
165 |
}
|
166 |
-
|
167 |
public function eof()
|
168 |
{
|
169 |
if (!isset($this->stream)) {
|
170 |
throw new \RuntimeException('Stream is detached');
|
171 |
}
|
172 |
-
|
173 |
-
return feof($this->stream);
|
174 |
}
|
175 |
-
|
176 |
public function tell()
|
177 |
{
|
178 |
if (!isset($this->stream)) {
|
179 |
throw new \RuntimeException('Stream is detached');
|
180 |
}
|
181 |
-
|
182 |
-
$result
|
183 |
-
|
184 |
-
if ($result === false) {
|
185 |
throw new \RuntimeException('Unable to determine stream position');
|
186 |
}
|
187 |
-
|
188 |
return $result;
|
189 |
}
|
190 |
-
|
191 |
public function rewind()
|
192 |
{
|
193 |
$this->seek(0);
|
194 |
}
|
195 |
-
|
196 |
-
public function seek($offset, $whence = SEEK_SET)
|
197 |
{
|
198 |
$whence = (int) $whence;
|
199 |
-
|
200 |
if (!isset($this->stream)) {
|
201 |
throw new \RuntimeException('Stream is detached');
|
202 |
}
|
203 |
if (!$this->seekable) {
|
204 |
throw new \RuntimeException('Stream is not seekable');
|
205 |
}
|
206 |
-
if (fseek($this->stream, $offset, $whence) === -1) {
|
207 |
-
throw new \RuntimeException('Unable to seek to stream position '
|
208 |
-
. $offset . ' with whence ' . var_export($whence, true));
|
209 |
}
|
210 |
}
|
211 |
-
|
212 |
public function read($length)
|
213 |
{
|
214 |
if (!isset($this->stream)) {
|
@@ -220,19 +183,15 @@ class Stream implements StreamInterface
|
|
220 |
if ($length < 0) {
|
221 |
throw new \RuntimeException('Length parameter cannot be negative');
|
222 |
}
|
223 |
-
|
224 |
if (0 === $length) {
|
225 |
return '';
|
226 |
}
|
227 |
-
|
228 |
-
|
229 |
-
if (false === $string) {
|
230 |
throw new \RuntimeException('Unable to read from stream');
|
231 |
}
|
232 |
-
|
233 |
return $string;
|
234 |
}
|
235 |
-
|
236 |
public function write($string)
|
237 |
{
|
238 |
if (!isset($this->stream)) {
|
@@ -241,30 +200,24 @@ class Stream implements StreamInterface
|
|
241 |
if (!$this->writable) {
|
242 |
throw new \RuntimeException('Cannot write to a non-writable stream');
|
243 |
}
|
244 |
-
|
245 |
// We can't know the size after writing anything
|
246 |
$this->size = null;
|
247 |
-
$result = fwrite($this->stream, $string);
|
248 |
-
|
249 |
-
if ($result === false) {
|
250 |
throw new \RuntimeException('Unable to write to stream');
|
251 |
}
|
252 |
-
|
253 |
return $result;
|
254 |
}
|
255 |
-
|
256 |
public function getMetadata($key = null)
|
257 |
{
|
258 |
if (!isset($this->stream)) {
|
259 |
return $key ? null : [];
|
260 |
} elseif (!$key) {
|
261 |
-
return $this->customMetadata + stream_get_meta_data($this->stream);
|
262 |
} elseif (isset($this->customMetadata[$key])) {
|
263 |
return $this->customMetadata[$key];
|
264 |
}
|
265 |
-
|
266 |
-
$meta = stream_get_meta_data($this->stream);
|
267 |
-
|
268 |
return isset($meta[$key]) ? $meta[$key] : null;
|
269 |
}
|
270 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* PHP stream implementation.
|
8 |
*
|
9 |
* @var $stream
|
10 |
*/
|
11 |
+
class Stream implements \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface
|
12 |
{
|
13 |
/**
|
14 |
* Resource modes.
|
18 |
* @see http://php.net/manual/function.fopen.php
|
19 |
* @see http://php.net/manual/en/function.gzopen.php
|
20 |
*/
|
21 |
+
const READABLE_MODES = '/r|a\\+|ab\\+|w\\+|wb\\+|x\\+|xb\\+|c\\+|cb\\+/';
|
22 |
+
const WRITABLE_MODES = '/a|w|r\\+|rb\\+|rw|x|c/';
|
|
|
23 |
private $stream;
|
24 |
private $size;
|
25 |
private $seekable;
|
27 |
private $writable;
|
28 |
private $uri;
|
29 |
private $customMetadata;
|
|
|
30 |
/**
|
31 |
* This constructor accepts an associative array of options.
|
32 |
*
|
43 |
*/
|
44 |
public function __construct($stream, $options = [])
|
45 |
{
|
46 |
+
if (!\is_resource($stream)) {
|
47 |
throw new \InvalidArgumentException('Stream must be a resource');
|
48 |
}
|
|
|
49 |
if (isset($options['size'])) {
|
50 |
$this->size = $options['size'];
|
51 |
}
|
52 |
+
$this->customMetadata = isset($options['metadata']) ? $options['metadata'] : [];
|
|
|
|
|
|
|
|
|
53 |
$this->stream = $stream;
|
54 |
+
$meta = \stream_get_meta_data($this->stream);
|
55 |
$this->seekable = $meta['seekable'];
|
56 |
+
$this->readable = (bool) \preg_match(self::READABLE_MODES, $meta['mode']);
|
57 |
+
$this->writable = (bool) \preg_match(self::WRITABLE_MODES, $meta['mode']);
|
58 |
$this->uri = $this->getMetadata('uri');
|
59 |
}
|
|
|
60 |
/**
|
61 |
* Closes the stream when the destructed
|
62 |
*/
|
64 |
{
|
65 |
$this->close();
|
66 |
}
|
|
|
67 |
public function __toString()
|
68 |
{
|
69 |
try {
|
75 |
return '';
|
76 |
}
|
77 |
}
|
|
|
78 |
public function getContents()
|
79 |
{
|
80 |
if (!isset($this->stream)) {
|
81 |
throw new \RuntimeException('Stream is detached');
|
82 |
}
|
83 |
+
$contents = \stream_get_contents($this->stream);
|
84 |
+
if ($contents === \false) {
|
|
|
|
|
85 |
throw new \RuntimeException('Unable to read stream contents');
|
86 |
}
|
|
|
87 |
return $contents;
|
88 |
}
|
|
|
89 |
public function close()
|
90 |
{
|
91 |
if (isset($this->stream)) {
|
92 |
+
if (\is_resource($this->stream)) {
|
93 |
+
\fclose($this->stream);
|
94 |
}
|
95 |
$this->detach();
|
96 |
}
|
97 |
}
|
|
|
98 |
public function detach()
|
99 |
{
|
100 |
if (!isset($this->stream)) {
|
101 |
return null;
|
102 |
}
|
|
|
103 |
$result = $this->stream;
|
104 |
unset($this->stream);
|
105 |
$this->size = $this->uri = null;
|
106 |
+
$this->readable = $this->writable = $this->seekable = \false;
|
|
|
107 |
return $result;
|
108 |
}
|
|
|
109 |
public function getSize()
|
110 |
{
|
111 |
if ($this->size !== null) {
|
112 |
return $this->size;
|
113 |
}
|
|
|
114 |
if (!isset($this->stream)) {
|
115 |
return null;
|
116 |
}
|
|
|
117 |
// Clear the stat cache if the stream has a URI
|
118 |
if ($this->uri) {
|
119 |
+
\clearstatcache(\true, $this->uri);
|
120 |
}
|
121 |
+
$stats = \fstat($this->stream);
|
|
|
122 |
if (isset($stats['size'])) {
|
123 |
$this->size = $stats['size'];
|
124 |
return $this->size;
|
125 |
}
|
|
|
126 |
return null;
|
127 |
}
|
|
|
128 |
public function isReadable()
|
129 |
{
|
130 |
return $this->readable;
|
131 |
}
|
|
|
132 |
public function isWritable()
|
133 |
{
|
134 |
return $this->writable;
|
135 |
}
|
|
|
136 |
public function isSeekable()
|
137 |
{
|
138 |
return $this->seekable;
|
139 |
}
|
|
|
140 |
public function eof()
|
141 |
{
|
142 |
if (!isset($this->stream)) {
|
143 |
throw new \RuntimeException('Stream is detached');
|
144 |
}
|
145 |
+
return \feof($this->stream);
|
|
|
146 |
}
|
|
|
147 |
public function tell()
|
148 |
{
|
149 |
if (!isset($this->stream)) {
|
150 |
throw new \RuntimeException('Stream is detached');
|
151 |
}
|
152 |
+
$result = \ftell($this->stream);
|
153 |
+
if ($result === \false) {
|
|
|
|
|
154 |
throw new \RuntimeException('Unable to determine stream position');
|
155 |
}
|
|
|
156 |
return $result;
|
157 |
}
|
|
|
158 |
public function rewind()
|
159 |
{
|
160 |
$this->seek(0);
|
161 |
}
|
162 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
163 |
{
|
164 |
$whence = (int) $whence;
|
|
|
165 |
if (!isset($this->stream)) {
|
166 |
throw new \RuntimeException('Stream is detached');
|
167 |
}
|
168 |
if (!$this->seekable) {
|
169 |
throw new \RuntimeException('Stream is not seekable');
|
170 |
}
|
171 |
+
if (\fseek($this->stream, $offset, $whence) === -1) {
|
172 |
+
throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . \var_export($whence, \true));
|
|
|
173 |
}
|
174 |
}
|
|
|
175 |
public function read($length)
|
176 |
{
|
177 |
if (!isset($this->stream)) {
|
183 |
if ($length < 0) {
|
184 |
throw new \RuntimeException('Length parameter cannot be negative');
|
185 |
}
|
|
|
186 |
if (0 === $length) {
|
187 |
return '';
|
188 |
}
|
189 |
+
$string = \fread($this->stream, $length);
|
190 |
+
if (\false === $string) {
|
|
|
191 |
throw new \RuntimeException('Unable to read from stream');
|
192 |
}
|
|
|
193 |
return $string;
|
194 |
}
|
|
|
195 |
public function write($string)
|
196 |
{
|
197 |
if (!isset($this->stream)) {
|
200 |
if (!$this->writable) {
|
201 |
throw new \RuntimeException('Cannot write to a non-writable stream');
|
202 |
}
|
|
|
203 |
// We can't know the size after writing anything
|
204 |
$this->size = null;
|
205 |
+
$result = \fwrite($this->stream, $string);
|
206 |
+
if ($result === \false) {
|
|
|
207 |
throw new \RuntimeException('Unable to write to stream');
|
208 |
}
|
|
|
209 |
return $result;
|
210 |
}
|
|
|
211 |
public function getMetadata($key = null)
|
212 |
{
|
213 |
if (!isset($this->stream)) {
|
214 |
return $key ? null : [];
|
215 |
} elseif (!$key) {
|
216 |
+
return $this->customMetadata + \stream_get_meta_data($this->stream);
|
217 |
} elseif (isset($this->customMetadata[$key])) {
|
218 |
return $this->customMetadata[$key];
|
219 |
}
|
220 |
+
$meta = \stream_get_meta_data($this->stream);
|
|
|
|
|
221 |
return isset($meta[$key]) ? $meta[$key] : null;
|
222 |
}
|
223 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/StreamDecoratorTrait.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Stream decorator trait
|
9 |
* @property StreamInterface stream
|
@@ -13,11 +12,10 @@ trait StreamDecoratorTrait
|
|
13 |
/**
|
14 |
* @param StreamInterface $stream Stream to decorate
|
15 |
*/
|
16 |
-
public function __construct(StreamInterface $stream)
|
17 |
{
|
18 |
$this->stream = $stream;
|
19 |
}
|
20 |
-
|
21 |
/**
|
22 |
* Magic method used to create a new stream if streams are not added in
|
23 |
* the constructor of a decorator (e.g., LazyOpenStream).
|
@@ -32,10 +30,8 @@ trait StreamDecoratorTrait
|
|
32 |
$this->stream = $this->createStream();
|
33 |
return $this->stream;
|
34 |
}
|
35 |
-
|
36 |
-
throw new \UnexpectedValueException("$name not found on class");
|
37 |
}
|
38 |
-
|
39 |
public function __toString()
|
40 |
{
|
41 |
try {
|
@@ -45,17 +41,14 @@ trait StreamDecoratorTrait
|
|
45 |
return $this->getContents();
|
46 |
} catch (\Exception $e) {
|
47 |
// Really, PHP? https://bugs.php.net/bug.php?id=53648
|
48 |
-
trigger_error('StreamDecorator::__toString exception: '
|
49 |
-
. (string) $e, E_USER_ERROR);
|
50 |
return '';
|
51 |
}
|
52 |
}
|
53 |
-
|
54 |
public function getContents()
|
55 |
{
|
56 |
-
return Utils::copyToString($this);
|
57 |
}
|
58 |
-
|
59 |
/**
|
60 |
* Allow decorators to implement custom methods
|
61 |
*
|
@@ -66,77 +59,62 @@ trait StreamDecoratorTrait
|
|
66 |
*/
|
67 |
public function __call($method, array $args)
|
68 |
{
|
69 |
-
$result = call_user_func_array([$this->stream, $method], $args);
|
70 |
-
|
71 |
// Always return the wrapped object if the result is a return $this
|
72 |
return $result === $this->stream ? $this : $result;
|
73 |
}
|
74 |
-
|
75 |
public function close()
|
76 |
{
|
77 |
$this->stream->close();
|
78 |
}
|
79 |
-
|
80 |
public function getMetadata($key = null)
|
81 |
{
|
82 |
return $this->stream->getMetadata($key);
|
83 |
}
|
84 |
-
|
85 |
public function detach()
|
86 |
{
|
87 |
return $this->stream->detach();
|
88 |
}
|
89 |
-
|
90 |
public function getSize()
|
91 |
{
|
92 |
return $this->stream->getSize();
|
93 |
}
|
94 |
-
|
95 |
public function eof()
|
96 |
{
|
97 |
return $this->stream->eof();
|
98 |
}
|
99 |
-
|
100 |
public function tell()
|
101 |
{
|
102 |
return $this->stream->tell();
|
103 |
}
|
104 |
-
|
105 |
public function isReadable()
|
106 |
{
|
107 |
return $this->stream->isReadable();
|
108 |
}
|
109 |
-
|
110 |
public function isWritable()
|
111 |
{
|
112 |
return $this->stream->isWritable();
|
113 |
}
|
114 |
-
|
115 |
public function isSeekable()
|
116 |
{
|
117 |
return $this->stream->isSeekable();
|
118 |
}
|
119 |
-
|
120 |
public function rewind()
|
121 |
{
|
122 |
$this->seek(0);
|
123 |
}
|
124 |
-
|
125 |
-
public function seek($offset, $whence = SEEK_SET)
|
126 |
{
|
127 |
$this->stream->seek($offset, $whence);
|
128 |
}
|
129 |
-
|
130 |
public function read($length)
|
131 |
{
|
132 |
return $this->stream->read($length);
|
133 |
}
|
134 |
-
|
135 |
public function write($string)
|
136 |
{
|
137 |
return $this->stream->write($string);
|
138 |
}
|
139 |
-
|
140 |
/**
|
141 |
* Implement in subclasses to dynamically create streams when requested.
|
142 |
*
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Stream decorator trait
|
8 |
* @property StreamInterface stream
|
12 |
/**
|
13 |
* @param StreamInterface $stream Stream to decorate
|
14 |
*/
|
15 |
+
public function __construct(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream)
|
16 |
{
|
17 |
$this->stream = $stream;
|
18 |
}
|
|
|
19 |
/**
|
20 |
* Magic method used to create a new stream if streams are not added in
|
21 |
* the constructor of a decorator (e.g., LazyOpenStream).
|
30 |
$this->stream = $this->createStream();
|
31 |
return $this->stream;
|
32 |
}
|
33 |
+
throw new \UnexpectedValueException("{$name} not found on class");
|
|
|
34 |
}
|
|
|
35 |
public function __toString()
|
36 |
{
|
37 |
try {
|
41 |
return $this->getContents();
|
42 |
} catch (\Exception $e) {
|
43 |
// Really, PHP? https://bugs.php.net/bug.php?id=53648
|
44 |
+
\trigger_error('StreamDecorator::__toString exception: ' . (string) $e, \E_USER_ERROR);
|
|
|
45 |
return '';
|
46 |
}
|
47 |
}
|
|
|
48 |
public function getContents()
|
49 |
{
|
50 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::copyToString($this);
|
51 |
}
|
|
|
52 |
/**
|
53 |
* Allow decorators to implement custom methods
|
54 |
*
|
59 |
*/
|
60 |
public function __call($method, array $args)
|
61 |
{
|
62 |
+
$result = \call_user_func_array([$this->stream, $method], $args);
|
|
|
63 |
// Always return the wrapped object if the result is a return $this
|
64 |
return $result === $this->stream ? $this : $result;
|
65 |
}
|
|
|
66 |
public function close()
|
67 |
{
|
68 |
$this->stream->close();
|
69 |
}
|
|
|
70 |
public function getMetadata($key = null)
|
71 |
{
|
72 |
return $this->stream->getMetadata($key);
|
73 |
}
|
|
|
74 |
public function detach()
|
75 |
{
|
76 |
return $this->stream->detach();
|
77 |
}
|
|
|
78 |
public function getSize()
|
79 |
{
|
80 |
return $this->stream->getSize();
|
81 |
}
|
|
|
82 |
public function eof()
|
83 |
{
|
84 |
return $this->stream->eof();
|
85 |
}
|
|
|
86 |
public function tell()
|
87 |
{
|
88 |
return $this->stream->tell();
|
89 |
}
|
|
|
90 |
public function isReadable()
|
91 |
{
|
92 |
return $this->stream->isReadable();
|
93 |
}
|
|
|
94 |
public function isWritable()
|
95 |
{
|
96 |
return $this->stream->isWritable();
|
97 |
}
|
|
|
98 |
public function isSeekable()
|
99 |
{
|
100 |
return $this->stream->isSeekable();
|
101 |
}
|
|
|
102 |
public function rewind()
|
103 |
{
|
104 |
$this->seek(0);
|
105 |
}
|
106 |
+
public function seek($offset, $whence = \SEEK_SET)
|
|
|
107 |
{
|
108 |
$this->stream->seek($offset, $whence);
|
109 |
}
|
|
|
110 |
public function read($length)
|
111 |
{
|
112 |
return $this->stream->read($length);
|
113 |
}
|
|
|
114 |
public function write($string)
|
115 |
{
|
116 |
return $this->stream->write($string);
|
117 |
}
|
|
|
118 |
/**
|
119 |
* Implement in subclasses to dynamically create streams when requested.
|
120 |
*
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/StreamWrapper.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\StreamInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Converts Guzzle streams into PHP stream resources.
|
9 |
*/
|
@@ -11,13 +10,10 @@ class StreamWrapper
|
|
11 |
{
|
12 |
/** @var resource */
|
13 |
public $context;
|
14 |
-
|
15 |
/** @var StreamInterface */
|
16 |
private $stream;
|
17 |
-
|
18 |
/** @var string r, r+, or w */
|
19 |
private $mode;
|
20 |
-
|
21 |
/**
|
22 |
* Returns a resource representing the stream.
|
23 |
*
|
@@ -27,22 +23,18 @@ class StreamWrapper
|
|
27 |
*
|
28 |
* @throws \InvalidArgumentException if stream is not readable or writable
|
29 |
*/
|
30 |
-
public static function getResource(StreamInterface $stream)
|
31 |
{
|
32 |
self::register();
|
33 |
-
|
34 |
if ($stream->isReadable()) {
|
35 |
$mode = $stream->isWritable() ? 'r+' : 'r';
|
36 |
} elseif ($stream->isWritable()) {
|
37 |
$mode = 'w';
|
38 |
} else {
|
39 |
-
throw new \InvalidArgumentException('The stream must be readable, '
|
40 |
-
. 'writable, or both.');
|
41 |
}
|
42 |
-
|
43 |
-
return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
|
44 |
}
|
45 |
-
|
46 |
/**
|
47 |
* Creates a stream context that can be used to open a stream as a php stream resource.
|
48 |
*
|
@@ -50,114 +42,62 @@ class StreamWrapper
|
|
50 |
*
|
51 |
* @return resource
|
52 |
*/
|
53 |
-
public static function createStreamContext(StreamInterface $stream)
|
54 |
{
|
55 |
-
return stream_context_create([
|
56 |
-
'guzzle' => ['stream' => $stream]
|
57 |
-
]);
|
58 |
}
|
59 |
-
|
60 |
/**
|
61 |
* Registers the stream wrapper if needed
|
62 |
*/
|
63 |
public static function register()
|
64 |
{
|
65 |
-
if (
|
66 |
-
stream_wrapper_register('guzzle', __CLASS__);
|
67 |
}
|
68 |
}
|
69 |
-
|
70 |
public function stream_open($path, $mode, $options, &$opened_path)
|
71 |
{
|
72 |
-
$options = stream_context_get_options($this->context);
|
73 |
-
|
74 |
if (!isset($options['guzzle']['stream'])) {
|
75 |
-
return false;
|
76 |
}
|
77 |
-
|
78 |
$this->mode = $mode;
|
79 |
$this->stream = $options['guzzle']['stream'];
|
80 |
-
|
81 |
-
return true;
|
82 |
}
|
83 |
-
|
84 |
public function stream_read($count)
|
85 |
{
|
86 |
return $this->stream->read($count);
|
87 |
}
|
88 |
-
|
89 |
public function stream_write($data)
|
90 |
{
|
91 |
return (int) $this->stream->write($data);
|
92 |
}
|
93 |
-
|
94 |
public function stream_tell()
|
95 |
{
|
96 |
return $this->stream->tell();
|
97 |
}
|
98 |
-
|
99 |
public function stream_eof()
|
100 |
{
|
101 |
return $this->stream->eof();
|
102 |
}
|
103 |
-
|
104 |
public function stream_seek($offset, $whence)
|
105 |
{
|
106 |
$this->stream->seek($offset, $whence);
|
107 |
-
|
108 |
-
return true;
|
109 |
}
|
110 |
-
|
111 |
public function stream_cast($cast_as)
|
112 |
{
|
113 |
-
$stream = clone
|
114 |
-
|
115 |
return $stream->detach();
|
116 |
}
|
117 |
-
|
118 |
public function stream_stat()
|
119 |
{
|
120 |
-
static $modeMap = [
|
121 |
-
|
122 |
-
'rb' => 33060,
|
123 |
-
'r+' => 33206,
|
124 |
-
'w' => 33188,
|
125 |
-
'wb' => 33188
|
126 |
-
];
|
127 |
-
|
128 |
-
return [
|
129 |
-
'dev' => 0,
|
130 |
-
'ino' => 0,
|
131 |
-
'mode' => $modeMap[$this->mode],
|
132 |
-
'nlink' => 0,
|
133 |
-
'uid' => 0,
|
134 |
-
'gid' => 0,
|
135 |
-
'rdev' => 0,
|
136 |
-
'size' => $this->stream->getSize() ?: 0,
|
137 |
-
'atime' => 0,
|
138 |
-
'mtime' => 0,
|
139 |
-
'ctime' => 0,
|
140 |
-
'blksize' => 0,
|
141 |
-
'blocks' => 0
|
142 |
-
];
|
143 |
}
|
144 |
-
|
145 |
public function url_stat($path, $flags)
|
146 |
{
|
147 |
-
return [
|
148 |
-
'dev' => 0,
|
149 |
-
'ino' => 0,
|
150 |
-
'mode' => 0,
|
151 |
-
'nlink' => 0,
|
152 |
-
'uid' => 0,
|
153 |
-
'gid' => 0,
|
154 |
-
'rdev' => 0,
|
155 |
-
'size' => 0,
|
156 |
-
'atime' => 0,
|
157 |
-
'mtime' => 0,
|
158 |
-
'ctime' => 0,
|
159 |
-
'blksize' => 0,
|
160 |
-
'blocks' => 0
|
161 |
-
];
|
162 |
}
|
163 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
6 |
/**
|
7 |
* Converts Guzzle streams into PHP stream resources.
|
8 |
*/
|
10 |
{
|
11 |
/** @var resource */
|
12 |
public $context;
|
|
|
13 |
/** @var StreamInterface */
|
14 |
private $stream;
|
|
|
15 |
/** @var string r, r+, or w */
|
16 |
private $mode;
|
|
|
17 |
/**
|
18 |
* Returns a resource representing the stream.
|
19 |
*
|
23 |
*
|
24 |
* @throws \InvalidArgumentException if stream is not readable or writable
|
25 |
*/
|
26 |
+
public static function getResource(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream)
|
27 |
{
|
28 |
self::register();
|
|
|
29 |
if ($stream->isReadable()) {
|
30 |
$mode = $stream->isWritable() ? 'r+' : 'r';
|
31 |
} elseif ($stream->isWritable()) {
|
32 |
$mode = 'w';
|
33 |
} else {
|
34 |
+
throw new \InvalidArgumentException('The stream must be readable, ' . 'writable, or both.');
|
|
|
35 |
}
|
36 |
+
return \fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
|
|
|
37 |
}
|
|
|
38 |
/**
|
39 |
* Creates a stream context that can be used to open a stream as a php stream resource.
|
40 |
*
|
42 |
*
|
43 |
* @return resource
|
44 |
*/
|
45 |
+
public static function createStreamContext(\PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface $stream)
|
46 |
{
|
47 |
+
return \stream_context_create(['guzzle' => ['stream' => $stream]]);
|
|
|
|
|
48 |
}
|
|
|
49 |
/**
|
50 |
* Registers the stream wrapper if needed
|
51 |
*/
|
52 |
public static function register()
|
53 |
{
|
54 |
+
if (!\in_array('guzzle', \stream_get_wrappers())) {
|
55 |
+
\stream_wrapper_register('guzzle', __CLASS__);
|
56 |
}
|
57 |
}
|
|
|
58 |
public function stream_open($path, $mode, $options, &$opened_path)
|
59 |
{
|
60 |
+
$options = \stream_context_get_options($this->context);
|
|
|
61 |
if (!isset($options['guzzle']['stream'])) {
|
62 |
+
return \false;
|
63 |
}
|
|
|
64 |
$this->mode = $mode;
|
65 |
$this->stream = $options['guzzle']['stream'];
|
66 |
+
return \true;
|
|
|
67 |
}
|
|
|
68 |
public function stream_read($count)
|
69 |
{
|
70 |
return $this->stream->read($count);
|
71 |
}
|
|
|
72 |
public function stream_write($data)
|
73 |
{
|
74 |
return (int) $this->stream->write($data);
|
75 |
}
|
|
|
76 |
public function stream_tell()
|
77 |
{
|
78 |
return $this->stream->tell();
|
79 |
}
|
|
|
80 |
public function stream_eof()
|
81 |
{
|
82 |
return $this->stream->eof();
|
83 |
}
|
|
|
84 |
public function stream_seek($offset, $whence)
|
85 |
{
|
86 |
$this->stream->seek($offset, $whence);
|
87 |
+
return \true;
|
|
|
88 |
}
|
|
|
89 |
public function stream_cast($cast_as)
|
90 |
{
|
91 |
+
$stream = clone $this->stream;
|
|
|
92 |
return $stream->detach();
|
93 |
}
|
|
|
94 |
public function stream_stat()
|
95 |
{
|
96 |
+
static $modeMap = ['r' => 33060, 'rb' => 33060, 'r+' => 33206, 'w' => 33188, 'wb' => 33188];
|
97 |
+
return ['dev' => 0, 'ino' => 0, 'mode' => $modeMap[$this->mode], 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $this->stream->getSize() ?: 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
|
|
99 |
public function url_stat($path, $flags)
|
100 |
{
|
101 |
+
return ['dev' => 0, 'ino' => 0, 'mode' => 0, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/UploadedFile.php
RENAMED
@@ -1,63 +1,45 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
-
use Psr\Http\Message\StreamInterface;
|
7 |
-
use Psr\Http\Message\UploadedFileInterface;
|
8 |
use RuntimeException;
|
9 |
-
|
10 |
-
class UploadedFile implements UploadedFileInterface
|
11 |
{
|
12 |
/**
|
13 |
* @var int[]
|
14 |
*/
|
15 |
-
private static $errors = [
|
16 |
-
UPLOAD_ERR_OK,
|
17 |
-
UPLOAD_ERR_INI_SIZE,
|
18 |
-
UPLOAD_ERR_FORM_SIZE,
|
19 |
-
UPLOAD_ERR_PARTIAL,
|
20 |
-
UPLOAD_ERR_NO_FILE,
|
21 |
-
UPLOAD_ERR_NO_TMP_DIR,
|
22 |
-
UPLOAD_ERR_CANT_WRITE,
|
23 |
-
UPLOAD_ERR_EXTENSION,
|
24 |
-
];
|
25 |
-
|
26 |
/**
|
27 |
* @var string
|
28 |
*/
|
29 |
private $clientFilename;
|
30 |
-
|
31 |
/**
|
32 |
* @var string
|
33 |
*/
|
34 |
private $clientMediaType;
|
35 |
-
|
36 |
/**
|
37 |
* @var int
|
38 |
*/
|
39 |
private $error;
|
40 |
-
|
41 |
/**
|
42 |
* @var null|string
|
43 |
*/
|
44 |
private $file;
|
45 |
-
|
46 |
/**
|
47 |
* @var bool
|
48 |
*/
|
49 |
-
private $moved = false;
|
50 |
-
|
51 |
/**
|
52 |
* @var int
|
53 |
*/
|
54 |
private $size;
|
55 |
-
|
56 |
/**
|
57 |
* @var StreamInterface|null
|
58 |
*/
|
59 |
private $stream;
|
60 |
-
|
61 |
/**
|
62 |
* @param StreamInterface|string|resource $streamOrFile
|
63 |
* @param int $size
|
@@ -65,23 +47,16 @@ class UploadedFile implements UploadedFileInterface
|
|
65 |
* @param string|null $clientFilename
|
66 |
* @param string|null $clientMediaType
|
67 |
*/
|
68 |
-
public function __construct(
|
69 |
-
|
70 |
-
$size,
|
71 |
-
$errorStatus,
|
72 |
-
$clientFilename = null,
|
73 |
-
$clientMediaType = null
|
74 |
-
) {
|
75 |
$this->setError($errorStatus);
|
76 |
$this->setSize($size);
|
77 |
$this->setClientFilename($clientFilename);
|
78 |
$this->setClientMediaType($clientMediaType);
|
79 |
-
|
80 |
if ($this->isOk()) {
|
81 |
$this->setStreamOrFile($streamOrFile);
|
82 |
}
|
83 |
}
|
84 |
-
|
85 |
/**
|
86 |
* Depending on the value set file or stream variable
|
87 |
*
|
@@ -91,19 +66,16 @@ class UploadedFile implements UploadedFileInterface
|
|
91 |
*/
|
92 |
private function setStreamOrFile($streamOrFile)
|
93 |
{
|
94 |
-
if (is_string($streamOrFile)) {
|
95 |
$this->file = $streamOrFile;
|
96 |
-
} elseif (is_resource($streamOrFile)) {
|
97 |
-
$this->stream = new Stream($streamOrFile);
|
98 |
-
} elseif ($streamOrFile instanceof StreamInterface) {
|
99 |
$this->stream = $streamOrFile;
|
100 |
} else {
|
101 |
-
throw new InvalidArgumentException(
|
102 |
-
'Invalid stream or file provided for UploadedFile'
|
103 |
-
);
|
104 |
}
|
105 |
}
|
106 |
-
|
107 |
/**
|
108 |
* @param int $error
|
109 |
*
|
@@ -111,21 +83,14 @@ class UploadedFile implements UploadedFileInterface
|
|
111 |
*/
|
112 |
private function setError($error)
|
113 |
{
|
114 |
-
if (false === is_int($error)) {
|
115 |
-
throw new InvalidArgumentException(
|
116 |
-
'Upload file error status must be an integer'
|
117 |
-
);
|
118 |
}
|
119 |
-
|
120 |
-
|
121 |
-
throw new InvalidArgumentException(
|
122 |
-
'Invalid error status for UploadedFile'
|
123 |
-
);
|
124 |
}
|
125 |
-
|
126 |
$this->error = $error;
|
127 |
}
|
128 |
-
|
129 |
/**
|
130 |
* @param int $size
|
131 |
*
|
@@ -133,33 +98,27 @@ class UploadedFile implements UploadedFileInterface
|
|
133 |
*/
|
134 |
private function setSize($size)
|
135 |
{
|
136 |
-
if (false === is_int($size)) {
|
137 |
-
throw new InvalidArgumentException(
|
138 |
-
'Upload file size must be an integer'
|
139 |
-
);
|
140 |
}
|
141 |
-
|
142 |
$this->size = $size;
|
143 |
}
|
144 |
-
|
145 |
/**
|
146 |
* @param mixed $param
|
147 |
* @return boolean
|
148 |
*/
|
149 |
private function isStringOrNull($param)
|
150 |
{
|
151 |
-
return in_array(gettype($param), ['string', 'NULL']);
|
152 |
}
|
153 |
-
|
154 |
/**
|
155 |
* @param mixed $param
|
156 |
* @return boolean
|
157 |
*/
|
158 |
private function isStringNotEmpty($param)
|
159 |
{
|
160 |
-
return is_string($param) && false === empty($param);
|
161 |
}
|
162 |
-
|
163 |
/**
|
164 |
* @param string|null $clientFilename
|
165 |
*
|
@@ -167,15 +126,11 @@ class UploadedFile implements UploadedFileInterface
|
|
167 |
*/
|
168 |
private function setClientFilename($clientFilename)
|
169 |
{
|
170 |
-
if (false === $this->isStringOrNull($clientFilename)) {
|
171 |
-
throw new InvalidArgumentException(
|
172 |
-
'Upload file client filename must be a string or null'
|
173 |
-
);
|
174 |
}
|
175 |
-
|
176 |
$this->clientFilename = $clientFilename;
|
177 |
}
|
178 |
-
|
179 |
/**
|
180 |
* @param string|null $clientMediaType
|
181 |
*
|
@@ -183,15 +138,11 @@ class UploadedFile implements UploadedFileInterface
|
|
183 |
*/
|
184 |
private function setClientMediaType($clientMediaType)
|
185 |
{
|
186 |
-
if (false === $this->isStringOrNull($clientMediaType)) {
|
187 |
-
throw new InvalidArgumentException(
|
188 |
-
'Upload file client media type must be a string or null'
|
189 |
-
);
|
190 |
}
|
191 |
-
|
192 |
$this->clientMediaType = $clientMediaType;
|
193 |
}
|
194 |
-
|
195 |
/**
|
196 |
* Return true if there is no upload error
|
197 |
*
|
@@ -199,9 +150,8 @@ class UploadedFile implements UploadedFileInterface
|
|
199 |
*/
|
200 |
private function isOk()
|
201 |
{
|
202 |
-
return $this->error === UPLOAD_ERR_OK;
|
203 |
}
|
204 |
-
|
205 |
/**
|
206 |
* @return boolean
|
207 |
*/
|
@@ -209,21 +159,18 @@ class UploadedFile implements UploadedFileInterface
|
|
209 |
{
|
210 |
return $this->moved;
|
211 |
}
|
212 |
-
|
213 |
/**
|
214 |
* @throws RuntimeException if is moved or not ok
|
215 |
*/
|
216 |
private function validateActive()
|
217 |
{
|
218 |
-
if (false === $this->isOk()) {
|
219 |
-
throw new RuntimeException('Cannot retrieve stream due to upload error');
|
220 |
}
|
221 |
-
|
222 |
if ($this->isMoved()) {
|
223 |
-
throw new RuntimeException('Cannot retrieve stream after it has already been moved');
|
224 |
}
|
225 |
}
|
226 |
-
|
227 |
/**
|
228 |
* {@inheritdoc}
|
229 |
*
|
@@ -232,14 +179,11 @@ class UploadedFile implements UploadedFileInterface
|
|
232 |
public function getStream()
|
233 |
{
|
234 |
$this->validateActive();
|
235 |
-
|
236 |
-
if ($this->stream instanceof StreamInterface) {
|
237 |
return $this->stream;
|
238 |
}
|
239 |
-
|
240 |
-
return new LazyOpenStream($this->file, 'r+');
|
241 |
}
|
242 |
-
|
243 |
/**
|
244 |
* {@inheritdoc}
|
245 |
*
|
@@ -256,33 +200,19 @@ class UploadedFile implements UploadedFileInterface
|
|
256 |
public function moveTo($targetPath)
|
257 |
{
|
258 |
$this->validateActive();
|
259 |
-
|
260 |
-
|
261 |
-
throw new InvalidArgumentException(
|
262 |
-
'Invalid path provided for move operation; must be a non-empty string'
|
263 |
-
);
|
264 |
}
|
265 |
-
|
266 |
if ($this->file) {
|
267 |
-
$this->moved = php_sapi_name() == 'cli'
|
268 |
-
? rename($this->file, $targetPath)
|
269 |
-
: move_uploaded_file($this->file, $targetPath);
|
270 |
} else {
|
271 |
-
Utils::copyToStream(
|
272 |
-
|
273 |
-
new LazyOpenStream($targetPath, 'w')
|
274 |
-
);
|
275 |
-
|
276 |
-
$this->moved = true;
|
277 |
}
|
278 |
-
|
279 |
-
|
280 |
-
throw new RuntimeException(
|
281 |
-
sprintf('Uploaded file could not be moved to %s', $targetPath)
|
282 |
-
);
|
283 |
}
|
284 |
}
|
285 |
-
|
286 |
/**
|
287 |
* {@inheritdoc}
|
288 |
*
|
@@ -292,7 +222,6 @@ class UploadedFile implements UploadedFileInterface
|
|
292 |
{
|
293 |
return $this->size;
|
294 |
}
|
295 |
-
|
296 |
/**
|
297 |
* {@inheritdoc}
|
298 |
*
|
@@ -303,7 +232,6 @@ class UploadedFile implements UploadedFileInterface
|
|
303 |
{
|
304 |
return $this->error;
|
305 |
}
|
306 |
-
|
307 |
/**
|
308 |
* {@inheritdoc}
|
309 |
*
|
@@ -314,7 +242,6 @@ class UploadedFile implements UploadedFileInterface
|
|
314 |
{
|
315 |
return $this->clientFilename;
|
316 |
}
|
317 |
-
|
318 |
/**
|
319 |
* {@inheritdoc}
|
320 |
*/
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
4 |
|
5 |
use InvalidArgumentException;
|
6 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface;
|
7 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UploadedFileInterface;
|
8 |
use RuntimeException;
|
9 |
+
class UploadedFile implements \PixelCaffeine\Dependencies\Psr\Http\Message\UploadedFileInterface
|
|
|
10 |
{
|
11 |
/**
|
12 |
* @var int[]
|
13 |
*/
|
14 |
+
private static $errors = [\UPLOAD_ERR_OK, \UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
private $clientFilename;
|
|
|
19 |
/**
|
20 |
* @var string
|
21 |
*/
|
22 |
private $clientMediaType;
|
|
|
23 |
/**
|
24 |
* @var int
|
25 |
*/
|
26 |
private $error;
|
|
|
27 |
/**
|
28 |
* @var null|string
|
29 |
*/
|
30 |
private $file;
|
|
|
31 |
/**
|
32 |
* @var bool
|
33 |
*/
|
34 |
+
private $moved = \false;
|
|
|
35 |
/**
|
36 |
* @var int
|
37 |
*/
|
38 |
private $size;
|
|
|
39 |
/**
|
40 |
* @var StreamInterface|null
|
41 |
*/
|
42 |
private $stream;
|
|
|
43 |
/**
|
44 |
* @param StreamInterface|string|resource $streamOrFile
|
45 |
* @param int $size
|
47 |
* @param string|null $clientFilename
|
48 |
* @param string|null $clientMediaType
|
49 |
*/
|
50 |
+
public function __construct($streamOrFile, $size, $errorStatus, $clientFilename = null, $clientMediaType = null)
|
51 |
+
{
|
|
|
|
|
|
|
|
|
|
|
52 |
$this->setError($errorStatus);
|
53 |
$this->setSize($size);
|
54 |
$this->setClientFilename($clientFilename);
|
55 |
$this->setClientMediaType($clientMediaType);
|
|
|
56 |
if ($this->isOk()) {
|
57 |
$this->setStreamOrFile($streamOrFile);
|
58 |
}
|
59 |
}
|
|
|
60 |
/**
|
61 |
* Depending on the value set file or stream variable
|
62 |
*
|
66 |
*/
|
67 |
private function setStreamOrFile($streamOrFile)
|
68 |
{
|
69 |
+
if (\is_string($streamOrFile)) {
|
70 |
$this->file = $streamOrFile;
|
71 |
+
} elseif (\is_resource($streamOrFile)) {
|
72 |
+
$this->stream = new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Stream($streamOrFile);
|
73 |
+
} elseif ($streamOrFile instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface) {
|
74 |
$this->stream = $streamOrFile;
|
75 |
} else {
|
76 |
+
throw new \InvalidArgumentException('Invalid stream or file provided for UploadedFile');
|
|
|
|
|
77 |
}
|
78 |
}
|
|
|
79 |
/**
|
80 |
* @param int $error
|
81 |
*
|
83 |
*/
|
84 |
private function setError($error)
|
85 |
{
|
86 |
+
if (\false === \is_int($error)) {
|
87 |
+
throw new \InvalidArgumentException('Upload file error status must be an integer');
|
|
|
|
|
88 |
}
|
89 |
+
if (\false === \in_array($error, \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UploadedFile::$errors)) {
|
90 |
+
throw new \InvalidArgumentException('Invalid error status for UploadedFile');
|
|
|
|
|
|
|
91 |
}
|
|
|
92 |
$this->error = $error;
|
93 |
}
|
|
|
94 |
/**
|
95 |
* @param int $size
|
96 |
*
|
98 |
*/
|
99 |
private function setSize($size)
|
100 |
{
|
101 |
+
if (\false === \is_int($size)) {
|
102 |
+
throw new \InvalidArgumentException('Upload file size must be an integer');
|
|
|
|
|
103 |
}
|
|
|
104 |
$this->size = $size;
|
105 |
}
|
|
|
106 |
/**
|
107 |
* @param mixed $param
|
108 |
* @return boolean
|
109 |
*/
|
110 |
private function isStringOrNull($param)
|
111 |
{
|
112 |
+
return \in_array(\gettype($param), ['string', 'NULL']);
|
113 |
}
|
|
|
114 |
/**
|
115 |
* @param mixed $param
|
116 |
* @return boolean
|
117 |
*/
|
118 |
private function isStringNotEmpty($param)
|
119 |
{
|
120 |
+
return \is_string($param) && \false === empty($param);
|
121 |
}
|
|
|
122 |
/**
|
123 |
* @param string|null $clientFilename
|
124 |
*
|
126 |
*/
|
127 |
private function setClientFilename($clientFilename)
|
128 |
{
|
129 |
+
if (\false === $this->isStringOrNull($clientFilename)) {
|
130 |
+
throw new \InvalidArgumentException('Upload file client filename must be a string or null');
|
|
|
|
|
131 |
}
|
|
|
132 |
$this->clientFilename = $clientFilename;
|
133 |
}
|
|
|
134 |
/**
|
135 |
* @param string|null $clientMediaType
|
136 |
*
|
138 |
*/
|
139 |
private function setClientMediaType($clientMediaType)
|
140 |
{
|
141 |
+
if (\false === $this->isStringOrNull($clientMediaType)) {
|
142 |
+
throw new \InvalidArgumentException('Upload file client media type must be a string or null');
|
|
|
|
|
143 |
}
|
|
|
144 |
$this->clientMediaType = $clientMediaType;
|
145 |
}
|
|
|
146 |
/**
|
147 |
* Return true if there is no upload error
|
148 |
*
|
150 |
*/
|
151 |
private function isOk()
|
152 |
{
|
153 |
+
return $this->error === \UPLOAD_ERR_OK;
|
154 |
}
|
|
|
155 |
/**
|
156 |
* @return boolean
|
157 |
*/
|
159 |
{
|
160 |
return $this->moved;
|
161 |
}
|
|
|
162 |
/**
|
163 |
* @throws RuntimeException if is moved or not ok
|
164 |
*/
|
165 |
private function validateActive()
|
166 |
{
|
167 |
+
if (\false === $this->isOk()) {
|
168 |
+
throw new \RuntimeException('Cannot retrieve stream due to upload error');
|
169 |
}
|
|
|
170 |
if ($this->isMoved()) {
|
171 |
+
throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
|
172 |
}
|
173 |
}
|
|
|
174 |
/**
|
175 |
* {@inheritdoc}
|
176 |
*
|
179 |
public function getStream()
|
180 |
{
|
181 |
$this->validateActive();
|
182 |
+
if ($this->stream instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\StreamInterface) {
|
|
|
183 |
return $this->stream;
|
184 |
}
|
185 |
+
return new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream($this->file, 'r+');
|
|
|
186 |
}
|
|
|
187 |
/**
|
188 |
* {@inheritdoc}
|
189 |
*
|
200 |
public function moveTo($targetPath)
|
201 |
{
|
202 |
$this->validateActive();
|
203 |
+
if (\false === $this->isStringNotEmpty($targetPath)) {
|
204 |
+
throw new \InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
|
|
|
|
|
|
|
205 |
}
|
|
|
206 |
if ($this->file) {
|
207 |
+
$this->moved = \php_sapi_name() == 'cli' ? \rename($this->file, $targetPath) : \move_uploaded_file($this->file, $targetPath);
|
|
|
|
|
208 |
} else {
|
209 |
+
\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Utils::copyToStream($this->getStream(), new \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\LazyOpenStream($targetPath, 'w'));
|
210 |
+
$this->moved = \true;
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
+
if (\false === $this->moved) {
|
213 |
+
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
|
|
|
|
|
|
|
214 |
}
|
215 |
}
|
|
|
216 |
/**
|
217 |
* {@inheritdoc}
|
218 |
*
|
222 |
{
|
223 |
return $this->size;
|
224 |
}
|
|
|
225 |
/**
|
226 |
* {@inheritdoc}
|
227 |
*
|
232 |
{
|
233 |
return $this->error;
|
234 |
}
|
|
|
235 |
/**
|
236 |
* {@inheritdoc}
|
237 |
*
|
242 |
{
|
243 |
return $this->clientFilename;
|
244 |
}
|
|
|
245 |
/**
|
246 |
* {@inheritdoc}
|
247 |
*/
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/Uri.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\UriInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* PSR-7 URI implementation.
|
9 |
*
|
@@ -11,7 +10,7 @@ use Psr\Http\Message\UriInterface;
|
|
11 |
* @author Tobias Schultze
|
12 |
* @author Matthew Weier O'Phinney
|
13 |
*/
|
14 |
-
class Uri implements UriInterface
|
15 |
{
|
16 |
/**
|
17 |
* Absolute http and https URIs require a host per RFC 7230 Section 2.7
|
@@ -20,46 +19,24 @@ class Uri implements UriInterface
|
|
20 |
* valid URI.
|
21 |
*/
|
22 |
const HTTP_DEFAULT_HOST = 'localhost';
|
23 |
-
|
24 |
-
private static $
|
25 |
-
|
26 |
-
'https' => 443,
|
27 |
-
'ftp' => 21,
|
28 |
-
'gopher' => 70,
|
29 |
-
'nntp' => 119,
|
30 |
-
'news' => 119,
|
31 |
-
'telnet' => 23,
|
32 |
-
'tn3270' => 23,
|
33 |
-
'imap' => 143,
|
34 |
-
'pop' => 110,
|
35 |
-
'ldap' => 389,
|
36 |
-
];
|
37 |
-
|
38 |
-
private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
|
39 |
-
private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
|
40 |
private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
|
41 |
-
|
42 |
/** @var string Uri scheme. */
|
43 |
private $scheme = '';
|
44 |
-
|
45 |
/** @var string Uri user info. */
|
46 |
private $userInfo = '';
|
47 |
-
|
48 |
/** @var string Uri host. */
|
49 |
private $host = '';
|
50 |
-
|
51 |
/** @var int|null Uri port. */
|
52 |
private $port;
|
53 |
-
|
54 |
/** @var string Uri path. */
|
55 |
private $path = '';
|
56 |
-
|
57 |
/** @var string Uri query string. */
|
58 |
private $query = '';
|
59 |
-
|
60 |
/** @var string Uri fragment. */
|
61 |
private $fragment = '';
|
62 |
-
|
63 |
/**
|
64 |
* @param string $uri URI to parse
|
65 |
*/
|
@@ -67,25 +44,17 @@ class Uri implements UriInterface
|
|
67 |
{
|
68 |
// weak type check to also accept null until we can add scalar type hints
|
69 |
if ($uri != '') {
|
70 |
-
$parts = parse_url($uri);
|
71 |
-
if ($parts === false) {
|
72 |
-
throw new \InvalidArgumentException("Unable to parse URI: $uri");
|
73 |
}
|
74 |
$this->applyParts($parts);
|
75 |
}
|
76 |
}
|
77 |
-
|
78 |
public function __toString()
|
79 |
{
|
80 |
-
return self::composeComponents(
|
81 |
-
$this->scheme,
|
82 |
-
$this->getAuthority(),
|
83 |
-
$this->path,
|
84 |
-
$this->query,
|
85 |
-
$this->fragment
|
86 |
-
);
|
87 |
}
|
88 |
-
|
89 |
/**
|
90 |
* Composes a URI reference string from its various components.
|
91 |
*
|
@@ -115,29 +84,22 @@ class Uri implements UriInterface
|
|
115 |
public static function composeComponents($scheme, $authority, $path, $query, $fragment)
|
116 |
{
|
117 |
$uri = '';
|
118 |
-
|
119 |
// weak type checks to also accept null until we can add scalar type hints
|
120 |
if ($scheme != '') {
|
121 |
$uri .= $scheme . ':';
|
122 |
}
|
123 |
-
|
124 |
-
if ($authority != ''|| $scheme === 'file') {
|
125 |
$uri .= '//' . $authority;
|
126 |
}
|
127 |
-
|
128 |
$uri .= $path;
|
129 |
-
|
130 |
if ($query != '') {
|
131 |
$uri .= '?' . $query;
|
132 |
}
|
133 |
-
|
134 |
if ($fragment != '') {
|
135 |
$uri .= '#' . $fragment;
|
136 |
}
|
137 |
-
|
138 |
return $uri;
|
139 |
}
|
140 |
-
|
141 |
/**
|
142 |
* Whether the URI has the default port of the current scheme.
|
143 |
*
|
@@ -148,12 +110,10 @@ class Uri implements UriInterface
|
|
148 |
*
|
149 |
* @return bool
|
150 |
*/
|
151 |
-
public static function isDefaultPort(UriInterface $uri)
|
152 |
{
|
153 |
-
return $uri->getPort() === null
|
154 |
-
|| (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
|
155 |
}
|
156 |
-
|
157 |
/**
|
158 |
* Whether the URI is absolute, i.e. it has a scheme.
|
159 |
*
|
@@ -172,11 +132,10 @@ class Uri implements UriInterface
|
|
172 |
* @see Uri::isRelativePathReference
|
173 |
* @link https://tools.ietf.org/html/rfc3986#section-4
|
174 |
*/
|
175 |
-
public static function isAbsolute(UriInterface $uri)
|
176 |
{
|
177 |
return $uri->getScheme() !== '';
|
178 |
}
|
179 |
-
|
180 |
/**
|
181 |
* Whether the URI is a network-path reference.
|
182 |
*
|
@@ -187,11 +146,10 @@ class Uri implements UriInterface
|
|
187 |
* @return bool
|
188 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
189 |
*/
|
190 |
-
public static function isNetworkPathReference(UriInterface $uri)
|
191 |
{
|
192 |
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
|
193 |
}
|
194 |
-
|
195 |
/**
|
196 |
* Whether the URI is a absolute-path reference.
|
197 |
*
|
@@ -202,14 +160,10 @@ class Uri implements UriInterface
|
|
202 |
* @return bool
|
203 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
204 |
*/
|
205 |
-
public static function isAbsolutePathReference(UriInterface $uri)
|
206 |
{
|
207 |
-
return $uri->getScheme() === ''
|
208 |
-
&& $uri->getAuthority() === ''
|
209 |
-
&& isset($uri->getPath()[0])
|
210 |
-
&& $uri->getPath()[0] === '/';
|
211 |
}
|
212 |
-
|
213 |
/**
|
214 |
* Whether the URI is a relative-path reference.
|
215 |
*
|
@@ -220,13 +174,10 @@ class Uri implements UriInterface
|
|
220 |
* @return bool
|
221 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
222 |
*/
|
223 |
-
public static function isRelativePathReference(UriInterface $uri)
|
224 |
{
|
225 |
-
return $uri->getScheme() === ''
|
226 |
-
&& $uri->getAuthority() === ''
|
227 |
-
&& (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
|
228 |
}
|
229 |
-
|
230 |
/**
|
231 |
* Whether the URI is a same-document reference.
|
232 |
*
|
@@ -240,20 +191,14 @@ class Uri implements UriInterface
|
|
240 |
* @return bool
|
241 |
* @link https://tools.ietf.org/html/rfc3986#section-4.4
|
242 |
*/
|
243 |
-
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
|
244 |
{
|
245 |
if ($base !== null) {
|
246 |
-
$uri = UriResolver::resolve($base, $uri);
|
247 |
-
|
248 |
-
return ($uri->getScheme() === $base->getScheme())
|
249 |
-
&& ($uri->getAuthority() === $base->getAuthority())
|
250 |
-
&& ($uri->getPath() === $base->getPath())
|
251 |
-
&& ($uri->getQuery() === $base->getQuery());
|
252 |
}
|
253 |
-
|
254 |
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
|
255 |
}
|
256 |
-
|
257 |
/**
|
258 |
* Removes dot segments from a path and returns the new path.
|
259 |
*
|
@@ -266,9 +211,8 @@ class Uri implements UriInterface
|
|
266 |
*/
|
267 |
public static function removeDotSegments($path)
|
268 |
{
|
269 |
-
return UriResolver::removeDotSegments($path);
|
270 |
}
|
271 |
-
|
272 |
/**
|
273 |
* Converts the relative URI into a new URI that is resolved against the base URI.
|
274 |
*
|
@@ -280,15 +224,13 @@ class Uri implements UriInterface
|
|
280 |
* @deprecated since version 1.4. Use UriResolver::resolve instead.
|
281 |
* @see UriResolver::resolve
|
282 |
*/
|
283 |
-
public static function resolve(UriInterface $base, $rel)
|
284 |
{
|
285 |
-
if (
|
286 |
$rel = new self($rel);
|
287 |
}
|
288 |
-
|
289 |
-
return UriResolver::resolve($base, $rel);
|
290 |
}
|
291 |
-
|
292 |
/**
|
293 |
* Creates a new URI with a specific query string value removed.
|
294 |
*
|
@@ -300,13 +242,11 @@ class Uri implements UriInterface
|
|
300 |
*
|
301 |
* @return UriInterface
|
302 |
*/
|
303 |
-
public static function withoutQueryValue(UriInterface $uri, $key)
|
304 |
{
|
305 |
$result = self::getFilteredQueryString($uri, [$key]);
|
306 |
-
|
307 |
-
return $uri->withQuery(implode('&', $result));
|
308 |
}
|
309 |
-
|
310 |
/**
|
311 |
* Creates a new URI with a specific query string value.
|
312 |
*
|
@@ -322,15 +262,12 @@ class Uri implements UriInterface
|
|
322 |
*
|
323 |
* @return UriInterface
|
324 |
*/
|
325 |
-
public static function withQueryValue(UriInterface $uri, $key, $value)
|
326 |
{
|
327 |
$result = self::getFilteredQueryString($uri, [$key]);
|
328 |
-
|
329 |
$result[] = self::generateQueryString($key, $value);
|
330 |
-
|
331 |
-
return $uri->withQuery(implode('&', $result));
|
332 |
}
|
333 |
-
|
334 |
/**
|
335 |
* Creates a new URI with multiple specific query string values.
|
336 |
*
|
@@ -341,17 +278,14 @@ class Uri implements UriInterface
|
|
341 |
*
|
342 |
* @return UriInterface
|
343 |
*/
|
344 |
-
public static function withQueryValues(UriInterface $uri, array $keyValueArray)
|
345 |
{
|
346 |
-
$result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
|
347 |
-
|
348 |
foreach ($keyValueArray as $key => $value) {
|
349 |
$result[] = self::generateQueryString($key, $value);
|
350 |
}
|
351 |
-
|
352 |
-
return $uri->withQuery(implode('&', $result));
|
353 |
}
|
354 |
-
|
355 |
/**
|
356 |
* Creates a URI from a hash of `parse_url` components.
|
357 |
*
|
@@ -367,167 +301,127 @@ class Uri implements UriInterface
|
|
367 |
$uri = new self();
|
368 |
$uri->applyParts($parts);
|
369 |
$uri->validateState();
|
370 |
-
|
371 |
return $uri;
|
372 |
}
|
373 |
-
|
374 |
public function getScheme()
|
375 |
{
|
376 |
return $this->scheme;
|
377 |
}
|
378 |
-
|
379 |
public function getAuthority()
|
380 |
{
|
381 |
$authority = $this->host;
|
382 |
if ($this->userInfo !== '') {
|
383 |
$authority = $this->userInfo . '@' . $authority;
|
384 |
}
|
385 |
-
|
386 |
if ($this->port !== null) {
|
387 |
$authority .= ':' . $this->port;
|
388 |
}
|
389 |
-
|
390 |
return $authority;
|
391 |
}
|
392 |
-
|
393 |
public function getUserInfo()
|
394 |
{
|
395 |
return $this->userInfo;
|
396 |
}
|
397 |
-
|
398 |
public function getHost()
|
399 |
{
|
400 |
return $this->host;
|
401 |
}
|
402 |
-
|
403 |
public function getPort()
|
404 |
{
|
405 |
return $this->port;
|
406 |
}
|
407 |
-
|
408 |
public function getPath()
|
409 |
{
|
410 |
return $this->path;
|
411 |
}
|
412 |
-
|
413 |
public function getQuery()
|
414 |
{
|
415 |
return $this->query;
|
416 |
}
|
417 |
-
|
418 |
public function getFragment()
|
419 |
{
|
420 |
return $this->fragment;
|
421 |
}
|
422 |
-
|
423 |
public function withScheme($scheme)
|
424 |
{
|
425 |
$scheme = $this->filterScheme($scheme);
|
426 |
-
|
427 |
if ($this->scheme === $scheme) {
|
428 |
return $this;
|
429 |
}
|
430 |
-
|
431 |
$new = clone $this;
|
432 |
$new->scheme = $scheme;
|
433 |
$new->removeDefaultPort();
|
434 |
$new->validateState();
|
435 |
-
|
436 |
return $new;
|
437 |
}
|
438 |
-
|
439 |
public function withUserInfo($user, $password = null)
|
440 |
{
|
441 |
$info = $this->filterUserInfoComponent($user);
|
442 |
if ($password !== null) {
|
443 |
$info .= ':' . $this->filterUserInfoComponent($password);
|
444 |
}
|
445 |
-
|
446 |
if ($this->userInfo === $info) {
|
447 |
return $this;
|
448 |
}
|
449 |
-
|
450 |
$new = clone $this;
|
451 |
$new->userInfo = $info;
|
452 |
$new->validateState();
|
453 |
-
|
454 |
return $new;
|
455 |
}
|
456 |
-
|
457 |
public function withHost($host)
|
458 |
{
|
459 |
$host = $this->filterHost($host);
|
460 |
-
|
461 |
if ($this->host === $host) {
|
462 |
return $this;
|
463 |
}
|
464 |
-
|
465 |
$new = clone $this;
|
466 |
$new->host = $host;
|
467 |
$new->validateState();
|
468 |
-
|
469 |
return $new;
|
470 |
}
|
471 |
-
|
472 |
public function withPort($port)
|
473 |
{
|
474 |
$port = $this->filterPort($port);
|
475 |
-
|
476 |
if ($this->port === $port) {
|
477 |
return $this;
|
478 |
}
|
479 |
-
|
480 |
$new = clone $this;
|
481 |
$new->port = $port;
|
482 |
$new->removeDefaultPort();
|
483 |
$new->validateState();
|
484 |
-
|
485 |
return $new;
|
486 |
}
|
487 |
-
|
488 |
public function withPath($path)
|
489 |
{
|
490 |
$path = $this->filterPath($path);
|
491 |
-
|
492 |
if ($this->path === $path) {
|
493 |
return $this;
|
494 |
}
|
495 |
-
|
496 |
$new = clone $this;
|
497 |
$new->path = $path;
|
498 |
$new->validateState();
|
499 |
-
|
500 |
return $new;
|
501 |
}
|
502 |
-
|
503 |
public function withQuery($query)
|
504 |
{
|
505 |
$query = $this->filterQueryAndFragment($query);
|
506 |
-
|
507 |
if ($this->query === $query) {
|
508 |
return $this;
|
509 |
}
|
510 |
-
|
511 |
$new = clone $this;
|
512 |
$new->query = $query;
|
513 |
-
|
514 |
return $new;
|
515 |
}
|
516 |
-
|
517 |
public function withFragment($fragment)
|
518 |
{
|
519 |
$fragment = $this->filterQueryAndFragment($fragment);
|
520 |
-
|
521 |
if ($this->fragment === $fragment) {
|
522 |
return $this;
|
523 |
}
|
524 |
-
|
525 |
$new = clone $this;
|
526 |
$new->fragment = $fragment;
|
527 |
-
|
528 |
return $new;
|
529 |
}
|
530 |
-
|
531 |
/**
|
532 |
* Apply parse_url parts to a URI.
|
533 |
*
|
@@ -535,34 +429,18 @@ class Uri implements UriInterface
|
|
535 |
*/
|
536 |
private function applyParts(array $parts)
|
537 |
{
|
538 |
-
$this->scheme = isset($parts['scheme'])
|
539 |
-
|
540 |
-
|
541 |
-
$this->
|
542 |
-
|
543 |
-
|
544 |
-
$this->
|
545 |
-
? $this->filterHost($parts['host'])
|
546 |
-
: '';
|
547 |
-
$this->port = isset($parts['port'])
|
548 |
-
? $this->filterPort($parts['port'])
|
549 |
-
: null;
|
550 |
-
$this->path = isset($parts['path'])
|
551 |
-
? $this->filterPath($parts['path'])
|
552 |
-
: '';
|
553 |
-
$this->query = isset($parts['query'])
|
554 |
-
? $this->filterQueryAndFragment($parts['query'])
|
555 |
-
: '';
|
556 |
-
$this->fragment = isset($parts['fragment'])
|
557 |
-
? $this->filterQueryAndFragment($parts['fragment'])
|
558 |
-
: '';
|
559 |
if (isset($parts['pass'])) {
|
560 |
$this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
|
561 |
}
|
562 |
-
|
563 |
$this->removeDefaultPort();
|
564 |
}
|
565 |
-
|
566 |
/**
|
567 |
* @param string $scheme
|
568 |
*
|
@@ -572,13 +450,11 @@ class Uri implements UriInterface
|
|
572 |
*/
|
573 |
private function filterScheme($scheme)
|
574 |
{
|
575 |
-
if (
|
576 |
throw new \InvalidArgumentException('Scheme must be a string');
|
577 |
}
|
578 |
-
|
579 |
-
return strtolower($scheme);
|
580 |
}
|
581 |
-
|
582 |
/**
|
583 |
* @param string $component
|
584 |
*
|
@@ -588,17 +464,11 @@ class Uri implements UriInterface
|
|
588 |
*/
|
589 |
private function filterUserInfoComponent($component)
|
590 |
{
|
591 |
-
if (
|
592 |
throw new \InvalidArgumentException('User info must be a string');
|
593 |
}
|
594 |
-
|
595 |
-
return preg_replace_callback(
|
596 |
-
'/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
|
597 |
-
[$this, 'rawurlencodeMatchZero'],
|
598 |
-
$component
|
599 |
-
);
|
600 |
}
|
601 |
-
|
602 |
/**
|
603 |
* @param string $host
|
604 |
*
|
@@ -608,13 +478,11 @@ class Uri implements UriInterface
|
|
608 |
*/
|
609 |
private function filterHost($host)
|
610 |
{
|
611 |
-
if (
|
612 |
throw new \InvalidArgumentException('Host must be a string');
|
613 |
}
|
614 |
-
|
615 |
-
return strtolower($host);
|
616 |
}
|
617 |
-
|
618 |
/**
|
619 |
* @param int|null $port
|
620 |
*
|
@@ -627,38 +495,29 @@ class Uri implements UriInterface
|
|
627 |
if ($port === null) {
|
628 |
return null;
|
629 |
}
|
630 |
-
|
631 |
$port = (int) $port;
|
632 |
if (0 > $port || 0xffff < $port) {
|
633 |
-
throw new \InvalidArgumentException(
|
634 |
-
sprintf('Invalid port: %d. Must be between 0 and 65535', $port)
|
635 |
-
);
|
636 |
}
|
637 |
-
|
638 |
return $port;
|
639 |
}
|
640 |
-
|
641 |
/**
|
642 |
* @param UriInterface $uri
|
643 |
* @param array $keys
|
644 |
*
|
645 |
* @return array
|
646 |
*/
|
647 |
-
private static function getFilteredQueryString(UriInterface $uri, array $keys)
|
648 |
{
|
649 |
$current = $uri->getQuery();
|
650 |
-
|
651 |
if ($current === '') {
|
652 |
return [];
|
653 |
}
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
|
658 |
-
return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true);
|
659 |
});
|
660 |
}
|
661 |
-
|
662 |
/**
|
663 |
* @param string $key
|
664 |
* @param string|null $value
|
@@ -670,22 +529,18 @@ class Uri implements UriInterface
|
|
670 |
// Query string separators ("=", "&") within the key or value need to be encoded
|
671 |
// (while preventing double-encoding) before setting the query string. All other
|
672 |
// chars that need percent-encoding will be encoded by withQuery().
|
673 |
-
$queryString = strtr($key, self::$replaceQuery);
|
674 |
-
|
675 |
if ($value !== null) {
|
676 |
-
$queryString .= '=' . strtr($value, self::$replaceQuery);
|
677 |
}
|
678 |
-
|
679 |
return $queryString;
|
680 |
}
|
681 |
-
|
682 |
private function removeDefaultPort()
|
683 |
{
|
684 |
if ($this->port !== null && self::isDefaultPort($this)) {
|
685 |
$this->port = null;
|
686 |
}
|
687 |
}
|
688 |
-
|
689 |
/**
|
690 |
* Filters the path of a URI
|
691 |
*
|
@@ -697,17 +552,11 @@ class Uri implements UriInterface
|
|
697 |
*/
|
698 |
private function filterPath($path)
|
699 |
{
|
700 |
-
if (
|
701 |
throw new \InvalidArgumentException('Path must be a string');
|
702 |
}
|
703 |
-
|
704 |
-
return preg_replace_callback(
|
705 |
-
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
|
706 |
-
[$this, 'rawurlencodeMatchZero'],
|
707 |
-
$path
|
708 |
-
);
|
709 |
}
|
710 |
-
|
711 |
/**
|
712 |
* Filters the query string or fragment of a URI.
|
713 |
*
|
@@ -719,42 +568,30 @@ class Uri implements UriInterface
|
|
719 |
*/
|
720 |
private function filterQueryAndFragment($str)
|
721 |
{
|
722 |
-
if (
|
723 |
throw new \InvalidArgumentException('Query and fragment must be a string');
|
724 |
}
|
725 |
-
|
726 |
-
return preg_replace_callback(
|
727 |
-
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
|
728 |
-
[$this, 'rawurlencodeMatchZero'],
|
729 |
-
$str
|
730 |
-
);
|
731 |
}
|
732 |
-
|
733 |
private function rawurlencodeMatchZero(array $match)
|
734 |
{
|
735 |
-
return rawurlencode($match[0]);
|
736 |
}
|
737 |
-
|
738 |
private function validateState()
|
739 |
{
|
740 |
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
|
741 |
$this->host = self::HTTP_DEFAULT_HOST;
|
742 |
}
|
743 |
-
|
744 |
if ($this->getAuthority() === '') {
|
745 |
-
if (0 === strpos($this->path, '//')) {
|
746 |
throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
|
747 |
}
|
748 |
-
if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
|
749 |
throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
|
750 |
}
|
751 |
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
|
752 |
-
|
753 |
-
|
754 |
-
'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
|
755 |
-
E_USER_DEPRECATED
|
756 |
-
);
|
757 |
-
$this->path = '/'. $this->path;
|
758 |
//throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
|
759 |
}
|
760 |
}
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
6 |
/**
|
7 |
* PSR-7 URI implementation.
|
8 |
*
|
10 |
* @author Tobias Schultze
|
11 |
* @author Matthew Weier O'Phinney
|
12 |
*/
|
13 |
+
class Uri implements \PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface
|
14 |
{
|
15 |
/**
|
16 |
* Absolute http and https URIs require a host per RFC 7230 Section 2.7
|
19 |
* valid URI.
|
20 |
*/
|
21 |
const HTTP_DEFAULT_HOST = 'localhost';
|
22 |
+
private static $defaultPorts = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389];
|
23 |
+
private static $charUnreserved = 'a-zA-Z0-9_\\-\\.~';
|
24 |
+
private static $charSubDelims = '!\\$&\'\\(\\)\\*\\+,;=';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
|
|
|
26 |
/** @var string Uri scheme. */
|
27 |
private $scheme = '';
|
|
|
28 |
/** @var string Uri user info. */
|
29 |
private $userInfo = '';
|
|
|
30 |
/** @var string Uri host. */
|
31 |
private $host = '';
|
|
|
32 |
/** @var int|null Uri port. */
|
33 |
private $port;
|
|
|
34 |
/** @var string Uri path. */
|
35 |
private $path = '';
|
|
|
36 |
/** @var string Uri query string. */
|
37 |
private $query = '';
|
|
|
38 |
/** @var string Uri fragment. */
|
39 |
private $fragment = '';
|
|
|
40 |
/**
|
41 |
* @param string $uri URI to parse
|
42 |
*/
|
44 |
{
|
45 |
// weak type check to also accept null until we can add scalar type hints
|
46 |
if ($uri != '') {
|
47 |
+
$parts = \parse_url($uri);
|
48 |
+
if ($parts === \false) {
|
49 |
+
throw new \InvalidArgumentException("Unable to parse URI: {$uri}");
|
50 |
}
|
51 |
$this->applyParts($parts);
|
52 |
}
|
53 |
}
|
|
|
54 |
public function __toString()
|
55 |
{
|
56 |
+
return self::composeComponents($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment);
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
|
|
58 |
/**
|
59 |
* Composes a URI reference string from its various components.
|
60 |
*
|
84 |
public static function composeComponents($scheme, $authority, $path, $query, $fragment)
|
85 |
{
|
86 |
$uri = '';
|
|
|
87 |
// weak type checks to also accept null until we can add scalar type hints
|
88 |
if ($scheme != '') {
|
89 |
$uri .= $scheme . ':';
|
90 |
}
|
91 |
+
if ($authority != '' || $scheme === 'file') {
|
|
|
92 |
$uri .= '//' . $authority;
|
93 |
}
|
|
|
94 |
$uri .= $path;
|
|
|
95 |
if ($query != '') {
|
96 |
$uri .= '?' . $query;
|
97 |
}
|
|
|
98 |
if ($fragment != '') {
|
99 |
$uri .= '#' . $fragment;
|
100 |
}
|
|
|
101 |
return $uri;
|
102 |
}
|
|
|
103 |
/**
|
104 |
* Whether the URI has the default port of the current scheme.
|
105 |
*
|
110 |
*
|
111 |
* @return bool
|
112 |
*/
|
113 |
+
public static function isDefaultPort(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
114 |
{
|
115 |
+
return $uri->getPort() === null || isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()];
|
|
|
116 |
}
|
|
|
117 |
/**
|
118 |
* Whether the URI is absolute, i.e. it has a scheme.
|
119 |
*
|
132 |
* @see Uri::isRelativePathReference
|
133 |
* @link https://tools.ietf.org/html/rfc3986#section-4
|
134 |
*/
|
135 |
+
public static function isAbsolute(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
136 |
{
|
137 |
return $uri->getScheme() !== '';
|
138 |
}
|
|
|
139 |
/**
|
140 |
* Whether the URI is a network-path reference.
|
141 |
*
|
146 |
* @return bool
|
147 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
148 |
*/
|
149 |
+
public static function isNetworkPathReference(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
150 |
{
|
151 |
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
|
152 |
}
|
|
|
153 |
/**
|
154 |
* Whether the URI is a absolute-path reference.
|
155 |
*
|
160 |
* @return bool
|
161 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
162 |
*/
|
163 |
+
public static function isAbsolutePathReference(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
164 |
{
|
165 |
+
return $uri->getScheme() === '' && $uri->getAuthority() === '' && isset($uri->getPath()[0]) && $uri->getPath()[0] === '/';
|
|
|
|
|
|
|
166 |
}
|
|
|
167 |
/**
|
168 |
* Whether the URI is a relative-path reference.
|
169 |
*
|
174 |
* @return bool
|
175 |
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
176 |
*/
|
177 |
+
public static function isRelativePathReference(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
178 |
{
|
179 |
+
return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
|
|
|
|
|
180 |
}
|
|
|
181 |
/**
|
182 |
* Whether the URI is a same-document reference.
|
183 |
*
|
191 |
* @return bool
|
192 |
* @link https://tools.ietf.org/html/rfc3986#section-4.4
|
193 |
*/
|
194 |
+
public static function isSameDocumentReference(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, \PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $base = null)
|
195 |
{
|
196 |
if ($base !== null) {
|
197 |
+
$uri = \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::resolve($base, $uri);
|
198 |
+
return $uri->getScheme() === $base->getScheme() && $uri->getAuthority() === $base->getAuthority() && $uri->getPath() === $base->getPath() && $uri->getQuery() === $base->getQuery();
|
|
|
|
|
|
|
|
|
199 |
}
|
|
|
200 |
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
|
201 |
}
|
|
|
202 |
/**
|
203 |
* Removes dot segments from a path and returns the new path.
|
204 |
*
|
211 |
*/
|
212 |
public static function removeDotSegments($path)
|
213 |
{
|
214 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::removeDotSegments($path);
|
215 |
}
|
|
|
216 |
/**
|
217 |
* Converts the relative URI into a new URI that is resolved against the base URI.
|
218 |
*
|
224 |
* @deprecated since version 1.4. Use UriResolver::resolve instead.
|
225 |
* @see UriResolver::resolve
|
226 |
*/
|
227 |
+
public static function resolve(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $base, $rel)
|
228 |
{
|
229 |
+
if (!$rel instanceof \PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface) {
|
230 |
$rel = new self($rel);
|
231 |
}
|
232 |
+
return \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::resolve($base, $rel);
|
|
|
233 |
}
|
|
|
234 |
/**
|
235 |
* Creates a new URI with a specific query string value removed.
|
236 |
*
|
242 |
*
|
243 |
* @return UriInterface
|
244 |
*/
|
245 |
+
public static function withoutQueryValue(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, $key)
|
246 |
{
|
247 |
$result = self::getFilteredQueryString($uri, [$key]);
|
248 |
+
return $uri->withQuery(\implode('&', $result));
|
|
|
249 |
}
|
|
|
250 |
/**
|
251 |
* Creates a new URI with a specific query string value.
|
252 |
*
|
262 |
*
|
263 |
* @return UriInterface
|
264 |
*/
|
265 |
+
public static function withQueryValue(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, $key, $value)
|
266 |
{
|
267 |
$result = self::getFilteredQueryString($uri, [$key]);
|
|
|
268 |
$result[] = self::generateQueryString($key, $value);
|
269 |
+
return $uri->withQuery(\implode('&', $result));
|
|
|
270 |
}
|
|
|
271 |
/**
|
272 |
* Creates a new URI with multiple specific query string values.
|
273 |
*
|
278 |
*
|
279 |
* @return UriInterface
|
280 |
*/
|
281 |
+
public static function withQueryValues(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, array $keyValueArray)
|
282 |
{
|
283 |
+
$result = self::getFilteredQueryString($uri, \array_keys($keyValueArray));
|
|
|
284 |
foreach ($keyValueArray as $key => $value) {
|
285 |
$result[] = self::generateQueryString($key, $value);
|
286 |
}
|
287 |
+
return $uri->withQuery(\implode('&', $result));
|
|
|
288 |
}
|
|
|
289 |
/**
|
290 |
* Creates a URI from a hash of `parse_url` components.
|
291 |
*
|
301 |
$uri = new self();
|
302 |
$uri->applyParts($parts);
|
303 |
$uri->validateState();
|
|
|
304 |
return $uri;
|
305 |
}
|
|
|
306 |
public function getScheme()
|
307 |
{
|
308 |
return $this->scheme;
|
309 |
}
|
|
|
310 |
public function getAuthority()
|
311 |
{
|
312 |
$authority = $this->host;
|
313 |
if ($this->userInfo !== '') {
|
314 |
$authority = $this->userInfo . '@' . $authority;
|
315 |
}
|
|
|
316 |
if ($this->port !== null) {
|
317 |
$authority .= ':' . $this->port;
|
318 |
}
|
|
|
319 |
return $authority;
|
320 |
}
|
|
|
321 |
public function getUserInfo()
|
322 |
{
|
323 |
return $this->userInfo;
|
324 |
}
|
|
|
325 |
public function getHost()
|
326 |
{
|
327 |
return $this->host;
|
328 |
}
|
|
|
329 |
public function getPort()
|
330 |
{
|
331 |
return $this->port;
|
332 |
}
|
|
|
333 |
public function getPath()
|
334 |
{
|
335 |
return $this->path;
|
336 |
}
|
|
|
337 |
public function getQuery()
|
338 |
{
|
339 |
return $this->query;
|
340 |
}
|
|
|
341 |
public function getFragment()
|
342 |
{
|
343 |
return $this->fragment;
|
344 |
}
|
|
|
345 |
public function withScheme($scheme)
|
346 |
{
|
347 |
$scheme = $this->filterScheme($scheme);
|
|
|
348 |
if ($this->scheme === $scheme) {
|
349 |
return $this;
|
350 |
}
|
|
|
351 |
$new = clone $this;
|
352 |
$new->scheme = $scheme;
|
353 |
$new->removeDefaultPort();
|
354 |
$new->validateState();
|
|
|
355 |
return $new;
|
356 |
}
|
|
|
357 |
public function withUserInfo($user, $password = null)
|
358 |
{
|
359 |
$info = $this->filterUserInfoComponent($user);
|
360 |
if ($password !== null) {
|
361 |
$info .= ':' . $this->filterUserInfoComponent($password);
|
362 |
}
|
|
|
363 |
if ($this->userInfo === $info) {
|
364 |
return $this;
|
365 |
}
|
|
|
366 |
$new = clone $this;
|
367 |
$new->userInfo = $info;
|
368 |
$new->validateState();
|
|
|
369 |
return $new;
|
370 |
}
|
|
|
371 |
public function withHost($host)
|
372 |
{
|
373 |
$host = $this->filterHost($host);
|
|
|
374 |
if ($this->host === $host) {
|
375 |
return $this;
|
376 |
}
|
|
|
377 |
$new = clone $this;
|
378 |
$new->host = $host;
|
379 |
$new->validateState();
|
|
|
380 |
return $new;
|
381 |
}
|
|
|
382 |
public function withPort($port)
|
383 |
{
|
384 |
$port = $this->filterPort($port);
|
|
|
385 |
if ($this->port === $port) {
|
386 |
return $this;
|
387 |
}
|
|
|
388 |
$new = clone $this;
|
389 |
$new->port = $port;
|
390 |
$new->removeDefaultPort();
|
391 |
$new->validateState();
|
|
|
392 |
return $new;
|
393 |
}
|
|
|
394 |
public function withPath($path)
|
395 |
{
|
396 |
$path = $this->filterPath($path);
|
|
|
397 |
if ($this->path === $path) {
|
398 |
return $this;
|
399 |
}
|
|
|
400 |
$new = clone $this;
|
401 |
$new->path = $path;
|
402 |
$new->validateState();
|
|
|
403 |
return $new;
|
404 |
}
|
|
|
405 |
public function withQuery($query)
|
406 |
{
|
407 |
$query = $this->filterQueryAndFragment($query);
|
|
|
408 |
if ($this->query === $query) {
|
409 |
return $this;
|
410 |
}
|
|
|
411 |
$new = clone $this;
|
412 |
$new->query = $query;
|
|
|
413 |
return $new;
|
414 |
}
|
|
|
415 |
public function withFragment($fragment)
|
416 |
{
|
417 |
$fragment = $this->filterQueryAndFragment($fragment);
|
|
|
418 |
if ($this->fragment === $fragment) {
|
419 |
return $this;
|
420 |
}
|
|
|
421 |
$new = clone $this;
|
422 |
$new->fragment = $fragment;
|
|
|
423 |
return $new;
|
424 |
}
|
|
|
425 |
/**
|
426 |
* Apply parse_url parts to a URI.
|
427 |
*
|
429 |
*/
|
430 |
private function applyParts(array $parts)
|
431 |
{
|
432 |
+
$this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : '';
|
433 |
+
$this->userInfo = isset($parts['user']) ? $this->filterUserInfoComponent($parts['user']) : '';
|
434 |
+
$this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : '';
|
435 |
+
$this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null;
|
436 |
+
$this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : '';
|
437 |
+
$this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : '';
|
438 |
+
$this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
if (isset($parts['pass'])) {
|
440 |
$this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
|
441 |
}
|
|
|
442 |
$this->removeDefaultPort();
|
443 |
}
|
|
|
444 |
/**
|
445 |
* @param string $scheme
|
446 |
*
|
450 |
*/
|
451 |
private function filterScheme($scheme)
|
452 |
{
|
453 |
+
if (!\is_string($scheme)) {
|
454 |
throw new \InvalidArgumentException('Scheme must be a string');
|
455 |
}
|
456 |
+
return \strtolower($scheme);
|
|
|
457 |
}
|
|
|
458 |
/**
|
459 |
* @param string $component
|
460 |
*
|
464 |
*/
|
465 |
private function filterUserInfoComponent($component)
|
466 |
{
|
467 |
+
if (!\is_string($component)) {
|
468 |
throw new \InvalidArgumentException('User info must be a string');
|
469 |
}
|
470 |
+
return \preg_replace_callback('/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component);
|
|
|
|
|
|
|
|
|
|
|
471 |
}
|
|
|
472 |
/**
|
473 |
* @param string $host
|
474 |
*
|
478 |
*/
|
479 |
private function filterHost($host)
|
480 |
{
|
481 |
+
if (!\is_string($host)) {
|
482 |
throw new \InvalidArgumentException('Host must be a string');
|
483 |
}
|
484 |
+
return \strtolower($host);
|
|
|
485 |
}
|
|
|
486 |
/**
|
487 |
* @param int|null $port
|
488 |
*
|
495 |
if ($port === null) {
|
496 |
return null;
|
497 |
}
|
|
|
498 |
$port = (int) $port;
|
499 |
if (0 > $port || 0xffff < $port) {
|
500 |
+
throw new \InvalidArgumentException(\sprintf('Invalid port: %d. Must be between 0 and 65535', $port));
|
|
|
|
|
501 |
}
|
|
|
502 |
return $port;
|
503 |
}
|
|
|
504 |
/**
|
505 |
* @param UriInterface $uri
|
506 |
* @param array $keys
|
507 |
*
|
508 |
* @return array
|
509 |
*/
|
510 |
+
private static function getFilteredQueryString(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, array $keys)
|
511 |
{
|
512 |
$current = $uri->getQuery();
|
|
|
513 |
if ($current === '') {
|
514 |
return [];
|
515 |
}
|
516 |
+
$decodedKeys = \array_map('rawurldecode', $keys);
|
517 |
+
return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) {
|
518 |
+
return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true);
|
|
|
|
|
519 |
});
|
520 |
}
|
|
|
521 |
/**
|
522 |
* @param string $key
|
523 |
* @param string|null $value
|
529 |
// Query string separators ("=", "&") within the key or value need to be encoded
|
530 |
// (while preventing double-encoding) before setting the query string. All other
|
531 |
// chars that need percent-encoding will be encoded by withQuery().
|
532 |
+
$queryString = \strtr($key, self::$replaceQuery);
|
|
|
533 |
if ($value !== null) {
|
534 |
+
$queryString .= '=' . \strtr($value, self::$replaceQuery);
|
535 |
}
|
|
|
536 |
return $queryString;
|
537 |
}
|
|
|
538 |
private function removeDefaultPort()
|
539 |
{
|
540 |
if ($this->port !== null && self::isDefaultPort($this)) {
|
541 |
$this->port = null;
|
542 |
}
|
543 |
}
|
|
|
544 |
/**
|
545 |
* Filters the path of a URI
|
546 |
*
|
552 |
*/
|
553 |
private function filterPath($path)
|
554 |
{
|
555 |
+
if (!\is_string($path)) {
|
556 |
throw new \InvalidArgumentException('Path must be a string');
|
557 |
}
|
558 |
+
return \preg_replace_callback('/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path);
|
|
|
|
|
|
|
|
|
|
|
559 |
}
|
|
|
560 |
/**
|
561 |
* Filters the query string or fragment of a URI.
|
562 |
*
|
568 |
*/
|
569 |
private function filterQueryAndFragment($str)
|
570 |
{
|
571 |
+
if (!\is_string($str)) {
|
572 |
throw new \InvalidArgumentException('Query and fragment must be a string');
|
573 |
}
|
574 |
+
return \preg_replace_callback('/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str);
|
|
|
|
|
|
|
|
|
|
|
575 |
}
|
|
|
576 |
private function rawurlencodeMatchZero(array $match)
|
577 |
{
|
578 |
+
return \rawurlencode($match[0]);
|
579 |
}
|
|
|
580 |
private function validateState()
|
581 |
{
|
582 |
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
|
583 |
$this->host = self::HTTP_DEFAULT_HOST;
|
584 |
}
|
|
|
585 |
if ($this->getAuthority() === '') {
|
586 |
+
if (0 === \strpos($this->path, '//')) {
|
587 |
throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
|
588 |
}
|
589 |
+
if ($this->scheme === '' && \false !== \strpos(\explode('/', $this->path, 2)[0], ':')) {
|
590 |
throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
|
591 |
}
|
592 |
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
|
593 |
+
@\trigger_error('The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', \E_USER_DEPRECATED);
|
594 |
+
$this->path = '/' . $this->path;
|
|
|
|
|
|
|
|
|
595 |
//throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
|
596 |
}
|
597 |
}
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/UriNormalizer.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\UriInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Provides methods to normalize and compare URIs.
|
9 |
*
|
@@ -20,14 +19,12 @@ final class UriNormalizer
|
|
20 |
* self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS
|
21 |
*/
|
22 |
const PRESERVING_NORMALIZATIONS = 63;
|
23 |
-
|
24 |
/**
|
25 |
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
|
26 |
*
|
27 |
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
|
28 |
*/
|
29 |
const CAPITALIZE_PERCENT_ENCODING = 1;
|
30 |
-
|
31 |
/**
|
32 |
* Decodes percent-encoded octets of unreserved characters.
|
33 |
*
|
@@ -38,14 +35,12 @@ final class UriNormalizer
|
|
38 |
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
|
39 |
*/
|
40 |
const DECODE_UNRESERVED_CHARACTERS = 2;
|
41 |
-
|
42 |
/**
|
43 |
* Converts the empty path to "/" for http and https URIs.
|
44 |
*
|
45 |
* Example: http://example.org → http://example.org/
|
46 |
*/
|
47 |
const CONVERT_EMPTY_PATH = 4;
|
48 |
-
|
49 |
/**
|
50 |
* Removes the default host of the given URI scheme from the URI.
|
51 |
*
|
@@ -58,14 +53,12 @@ final class UriNormalizer
|
|
58 |
* Example: file://localhost/myfile → file:///myfile
|
59 |
*/
|
60 |
const REMOVE_DEFAULT_HOST = 8;
|
61 |
-
|
62 |
/**
|
63 |
* Removes the default port of the given URI scheme from the URI.
|
64 |
*
|
65 |
* Example: http://example.org:80/ → http://example.org/
|
66 |
*/
|
67 |
const REMOVE_DEFAULT_PORT = 16;
|
68 |
-
|
69 |
/**
|
70 |
* Removes unnecessary dot-segments.
|
71 |
*
|
@@ -75,7 +68,6 @@ final class UriNormalizer
|
|
75 |
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
|
76 |
*/
|
77 |
const REMOVE_DOT_SEGMENTS = 32;
|
78 |
-
|
79 |
/**
|
80 |
* Paths which include two or more adjacent slashes are converted to one.
|
81 |
*
|
@@ -86,7 +78,6 @@ final class UriNormalizer
|
|
86 |
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
|
87 |
*/
|
88 |
const REMOVE_DUPLICATE_SLASHES = 64;
|
89 |
-
|
90 |
/**
|
91 |
* Sort query parameters with their values in alphabetical order.
|
92 |
*
|
@@ -99,7 +90,6 @@ final class UriNormalizer
|
|
99 |
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
|
100 |
*/
|
101 |
const SORT_QUERY_PARAMETERS = 128;
|
102 |
-
|
103 |
/**
|
104 |
* Returns a normalized URI.
|
105 |
*
|
@@ -117,47 +107,36 @@ final class UriNormalizer
|
|
117 |
* @return UriInterface The normalized URI
|
118 |
* @link https://tools.ietf.org/html/rfc3986#section-6.2
|
119 |
*/
|
120 |
-
public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS)
|
121 |
{
|
122 |
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
|
123 |
$uri = self::capitalizePercentEncoding($uri);
|
124 |
}
|
125 |
-
|
126 |
if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
|
127 |
$uri = self::decodeUnreservedCharacters($uri);
|
128 |
}
|
129 |
-
|
130 |
-
if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' &&
|
131 |
-
($uri->getScheme() === 'http' || $uri->getScheme() === 'https')
|
132 |
-
) {
|
133 |
$uri = $uri->withPath('/');
|
134 |
}
|
135 |
-
|
136 |
if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
|
137 |
$uri = $uri->withHost('');
|
138 |
}
|
139 |
-
|
140 |
-
if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) {
|
141 |
$uri = $uri->withPort(null);
|
142 |
}
|
143 |
-
|
144 |
-
|
145 |
-
$uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath()));
|
146 |
}
|
147 |
-
|
148 |
if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
|
149 |
-
$uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath()));
|
150 |
}
|
151 |
-
|
152 |
if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
|
153 |
-
$queryKeyValues = explode('&', $uri->getQuery());
|
154 |
-
sort($queryKeyValues);
|
155 |
-
$uri = $uri->withQuery(implode('&', $queryKeyValues));
|
156 |
}
|
157 |
-
|
158 |
return $uri;
|
159 |
}
|
160 |
-
|
161 |
/**
|
162 |
* Whether two URIs can be considered equivalent.
|
163 |
*
|
@@ -173,43 +152,26 @@ final class UriNormalizer
|
|
173 |
* @return bool
|
174 |
* @link https://tools.ietf.org/html/rfc3986#section-6.1
|
175 |
*/
|
176 |
-
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS)
|
177 |
{
|
178 |
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
|
179 |
}
|
180 |
-
|
181 |
-
private static function capitalizePercentEncoding(UriInterface $uri)
|
182 |
{
|
183 |
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
184 |
-
|
185 |
$callback = function (array $match) {
|
186 |
-
return strtoupper($match[0]);
|
187 |
};
|
188 |
-
|
189 |
-
return
|
190 |
-
$uri->withPath(
|
191 |
-
preg_replace_callback($regex, $callback, $uri->getPath())
|
192 |
-
)->withQuery(
|
193 |
-
preg_replace_callback($regex, $callback, $uri->getQuery())
|
194 |
-
);
|
195 |
}
|
196 |
-
|
197 |
-
private static function decodeUnreservedCharacters(UriInterface $uri)
|
198 |
{
|
199 |
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
200 |
-
|
201 |
$callback = function (array $match) {
|
202 |
-
return rawurldecode($match[0]);
|
203 |
};
|
204 |
-
|
205 |
-
return
|
206 |
-
$uri->withPath(
|
207 |
-
preg_replace_callback($regex, $callback, $uri->getPath())
|
208 |
-
)->withQuery(
|
209 |
-
preg_replace_callback($regex, $callback, $uri->getQuery())
|
210 |
-
);
|
211 |
}
|
212 |
-
|
213 |
private function __construct()
|
214 |
{
|
215 |
// cannot be instantiated
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
6 |
/**
|
7 |
* Provides methods to normalize and compare URIs.
|
8 |
*
|
19 |
* self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS
|
20 |
*/
|
21 |
const PRESERVING_NORMALIZATIONS = 63;
|
|
|
22 |
/**
|
23 |
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
|
24 |
*
|
25 |
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
|
26 |
*/
|
27 |
const CAPITALIZE_PERCENT_ENCODING = 1;
|
|
|
28 |
/**
|
29 |
* Decodes percent-encoded octets of unreserved characters.
|
30 |
*
|
35 |
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
|
36 |
*/
|
37 |
const DECODE_UNRESERVED_CHARACTERS = 2;
|
|
|
38 |
/**
|
39 |
* Converts the empty path to "/" for http and https URIs.
|
40 |
*
|
41 |
* Example: http://example.org → http://example.org/
|
42 |
*/
|
43 |
const CONVERT_EMPTY_PATH = 4;
|
|
|
44 |
/**
|
45 |
* Removes the default host of the given URI scheme from the URI.
|
46 |
*
|
53 |
* Example: file://localhost/myfile → file:///myfile
|
54 |
*/
|
55 |
const REMOVE_DEFAULT_HOST = 8;
|
|
|
56 |
/**
|
57 |
* Removes the default port of the given URI scheme from the URI.
|
58 |
*
|
59 |
* Example: http://example.org:80/ → http://example.org/
|
60 |
*/
|
61 |
const REMOVE_DEFAULT_PORT = 16;
|
|
|
62 |
/**
|
63 |
* Removes unnecessary dot-segments.
|
64 |
*
|
68 |
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
|
69 |
*/
|
70 |
const REMOVE_DOT_SEGMENTS = 32;
|
|
|
71 |
/**
|
72 |
* Paths which include two or more adjacent slashes are converted to one.
|
73 |
*
|
78 |
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
|
79 |
*/
|
80 |
const REMOVE_DUPLICATE_SLASHES = 64;
|
|
|
81 |
/**
|
82 |
* Sort query parameters with their values in alphabetical order.
|
83 |
*
|
90 |
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
|
91 |
*/
|
92 |
const SORT_QUERY_PARAMETERS = 128;
|
|
|
93 |
/**
|
94 |
* Returns a normalized URI.
|
95 |
*
|
107 |
* @return UriInterface The normalized URI
|
108 |
* @link https://tools.ietf.org/html/rfc3986#section-6.2
|
109 |
*/
|
110 |
+
public static function normalize(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS)
|
111 |
{
|
112 |
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
|
113 |
$uri = self::capitalizePercentEncoding($uri);
|
114 |
}
|
|
|
115 |
if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
|
116 |
$uri = self::decodeUnreservedCharacters($uri);
|
117 |
}
|
118 |
+
if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')) {
|
|
|
|
|
|
|
119 |
$uri = $uri->withPath('/');
|
120 |
}
|
|
|
121 |
if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
|
122 |
$uri = $uri->withHost('');
|
123 |
}
|
124 |
+
if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && \PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Uri::isDefaultPort($uri)) {
|
|
|
125 |
$uri = $uri->withPort(null);
|
126 |
}
|
127 |
+
if ($flags & self::REMOVE_DOT_SEGMENTS && !\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\Uri::isRelativePathReference($uri)) {
|
128 |
+
$uri = $uri->withPath(\PixelCaffeine\Dependencies\GuzzleHttp\Psr7\UriResolver::removeDotSegments($uri->getPath()));
|
|
|
129 |
}
|
|
|
130 |
if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
|
131 |
+
$uri = $uri->withPath(\preg_replace('#//++#', '/', $uri->getPath()));
|
132 |
}
|
|
|
133 |
if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
|
134 |
+
$queryKeyValues = \explode('&', $uri->getQuery());
|
135 |
+
\sort($queryKeyValues);
|
136 |
+
$uri = $uri->withQuery(\implode('&', $queryKeyValues));
|
137 |
}
|
|
|
138 |
return $uri;
|
139 |
}
|
|
|
140 |
/**
|
141 |
* Whether two URIs can be considered equivalent.
|
142 |
*
|
152 |
* @return bool
|
153 |
* @link https://tools.ietf.org/html/rfc3986#section-6.1
|
154 |
*/
|
155 |
+
public static function isEquivalent(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri1, \PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS)
|
156 |
{
|
157 |
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
|
158 |
}
|
159 |
+
private static function capitalizePercentEncoding(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
|
|
160 |
{
|
161 |
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
|
|
162 |
$callback = function (array $match) {
|
163 |
+
return \strtoupper($match[0]);
|
164 |
};
|
165 |
+
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
+
private static function decodeUnreservedCharacters(\PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface $uri)
|
|
|
168 |
{
|
169 |
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
|
|
170 |
$callback = function (array $match) {
|
171 |
+
return \rawurldecode($match[0]);
|
172 |
};
|
173 |
+
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
|
|
175 |
private function __construct()
|
176 |
{
|
177 |
// cannot be instantiated
|
{vendor → third-party/vendor}/guzzlehttp/psr7/src/UriResolver.php
RENAMED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
namespace GuzzleHttp\Psr7;
|
4 |
-
|
5 |
-
use Psr\Http\Message\UriInterface;
|
6 |
|
|
|
7 |
/**
|
8 |
* Resolves a URI reference in the context of a base URI and the opposite way.
|
9 |
*
|
@@ -26,19 +25,16 @@ final class UriResolver
|
|
26 |
if ($path === '' || $path === '/') {
|
27 |
return $path;
|
28 |
}
|
29 |
-
|
30 |
$results = [];
|
31 |
-
$segments = explode('/', $path);
|
32 |
foreach ($segments as $segment) {
|
33 |
if ($segment === '..') {
|
34 |
-
array_pop($results);
|
35 |
} elseif ($segment !== '.') {
|
36 |
$results[] = $segment;
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
$newPath = implode('/', $results);
|
41 |
-
|
42 |
if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !=
|
1 |
<?php
|
2 |
|
3 |
+
namespace PixelCaffeine\Dependencies\GuzzleHttp\Psr7;
|
|
|
|
|
4 |
|
5 |
+
use PixelCaffeine\Dependencies\Psr\Http\Message\UriInterface;
|
6 |
/**
|
7 |
* Resolves a URI reference in the context of a base URI and the opposite way.
|
8 |
*
|
25 |
if ($path === '' || $path === '/') {
|
26 |
return $path;
|
27 |
}
|
|
|
28 |
$results = [];
|
29 |
+
$segments = \explode('/', $path);
|
30 |
foreach ($segments as $segment) {
|
31 |
if ($segment === '..') {
|
32 |
+
\array_pop($results);
|
33 |
} elseif ($segment !== '.') {
|
34 |
$results[] = $segment;
|
35 |
}
|
36 |
}
|
37 |
+
$newPath = \implode('/', $results);
|
|
|
|
|
38 |
if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !=
|