@@ -13,7 +13,7 @@ A library for creating SDKs in PHP with support for:
1313- Event listeners;
1414- ...and more.
1515
16- All methods are public for full end user hackability 🔥.
16+ All methods are public for full hackability 🔥.
1717
1818## Requirements
1919
@@ -144,7 +144,7 @@ class YourApi extends Api
144144
145145By default, this method will return a ` string ` as it will be the response of the request as is.
146146If you want to change how the response is handled in all requests (for example, decode a JSON string into an array),
147- check the [ ` addResponseContentsHandler ` ] ( #addresponsecontentshandler ) method in the [ Event Listeners] ( #event-listeners ) section.
147+ check the [ ` addResponseContentsListener ` ] ( #addresponsecontentslistener ) method in the [ Event Listeners] ( #event-listeners ) section.
148148
149149#### ` buildPath `
150150
@@ -472,7 +472,7 @@ The `addResponseContentsListener` method is used to manipulate the response that
472472This event listener will be applied to every API request.
473473
474474``` php
475- $this->addResponseContentsListener(callable $handler , int $priority = 0): self;
475+ $this->addResponseContentsListener(callable $listener , int $priority = 0): self;
476476```
477477
478478For example, if the API responses are JSON strings, you can use this event listener to decode them into arrays:
@@ -527,7 +527,7 @@ Event listeners are then executed from the highest priority to the lowest:
527527
528528``` php
529529use ProgrammatorDev\Api\Api;
530- use ProgrammatorDev\Api\Event\PostRequestEvent ;
530+ use ProgrammatorDev\Api\Event\ResponseContentsEvent ;
531531
532532class YourApi extends Api
533533{
@@ -538,13 +538,13 @@ class YourApi extends Api
538538
539539 // executed last (lower priority)
540540 $this->addResponseContentsListener(
541- listener: function(PostRequestEvent $event) { ... },
541+ listener: function(ResponseContentsEvent $event) { ... },
542542 priority: 0
543543 );
544544
545545 // executed first (higher priority)
546546 $this->addResponseContentsListener(
547- listener: function(PostRequestEvent $event) { ... },
547+ listener: function(ResponseContentsEvent $event) { ... },
548548 priority: 10
549549 );
550550 }
@@ -558,21 +558,21 @@ For that, you can use the `stopPropagation()` method:
558558
559559``` php
560560use ProgrammatorDev\Api\Api;
561- use ProgrammatorDev\Api\Event\PostRequestEvent ;
561+ use ProgrammatorDev\Api\Event\ResponseContentsEvent ;
562562
563563class YourApi extends Api
564564{
565565 public function __construct()
566566 {
567- $this->addResponseContentsListener(function(PostRequestEvent $event) {
567+ $this->addResponseContentsListener(function(ResponseContentsEvent $event) {
568568 // stop propagation so future listeners of this event will not be called
569569 $event->stopPropagation();
570570 });
571571
572572 // this listener will not be called
573- $this->addResponseContentsListener(function(PostRequestEvent $event) {
573+ $this->addResponseContentsListener(function(ResponseContentsEvent $event) {
574574 // ...
575- });
575+ });
576576 }
577577}
578578```
@@ -849,11 +849,11 @@ class YourApi extends Api
849849 {
850850 parent::__construct();
851851
852- $this->configureOptions($options);
852+ $this->options = $this-> configureOptions($options);
853853 $this->configureApi();
854854 }
855855
856- private function configureOptions(array $options): void
856+ private function configureOptions(array $options): array
857857 {
858858 // set defaults values, if none were provided
859859 $this->optionsResolver->setDefault('timezone', 'UTC');
@@ -867,8 +867,8 @@ class YourApi extends Api
867867 $this->optionsResolver->setAllowedValues('timezone', \DateTimeZone::listIdentifiers());
868868 $this->optionsResolver->setAllowedValues('language', ['en', 'pt']);
869869
870- // resolve and set to options property
871- $this->options = $this->optionsResolver->resolve($options);
870+ // return resolved options
871+ return $this->optionsResolver->resolve($options);
872872 }
873873
874874 private function configureApi(): void
@@ -906,7 +906,12 @@ $api = new YourApi([
906906$posts = $api->getPosts();
907907```
908908
909- For all available methods, check the official page documentation [ here] ( https://symfony.com/doc/current/components/options_resolver.html ) .
909+ For all available methods, check the official page [ documentation] ( https://symfony.com/doc/current/components/options_resolver.html ) .
910+
911+ ## Libraries using PHP API SDK
912+
913+ - [ programmatordev/openweathermap-php-api] ( https://github.com/programmatordev/openweathermap-php-api )
914+ - [ programmatordev/sportmonksfootball-php-api] ( https://github.com/programmatordev/sportmonksfootball-php-api )
910915
911916## Contributing
912917
0 commit comments