Skip to content

Commit

Permalink
transform to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
rem42 committed Apr 11, 2020
1 parent 44e83da commit 9967799
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"ext-soap": "If you need to support Soap request"
},
"autoload": {
"psr-0": {
"Scraper\\Scraper\\": "src/"
},
"psr-4": {
"Scraper\\Scraper\\": "src/"
}
Expand Down
23 changes: 0 additions & 23 deletions src/Adapter/Adapter.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Adapter/AdapterInterface.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/Annotation/ExtractAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ protected function recursive(\ReflectionClass $reflectionClass = null): void
$this->recursive($parentClass);
}

if ($annotation = $this->reader->getClassAnnotation($reflectionClass, Scraper::class)) {
/* @var Scraper $annotation */
$annotation = $this->reader->getClassAnnotation($reflectionClass, Scraper::class);

if ($annotation instanceof Scraper) {
$this->extractAnnotation($annotation);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Scraper\Scraper\Request\RequestBearer;
use Scraper\Scraper\Request\RequestBody;
use Scraper\Scraper\Request\RequestHeaders;
use Scraper\Scraper\Request\RequestQuery;
use Scraper\Scraper\Request\ScraperRequest;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand Down Expand Up @@ -38,6 +39,10 @@ public function send(ScraperRequest $request): object
$options['headers'] = $this->request->getHeaders();
}

if ($this->request instanceof RequestQuery) {
$options['query'] = $this->request->getQuery();
}

if ($this->request instanceof RequestBody) {
$options['body'] = $this->request->getBody();
}
Expand Down
3 changes: 3 additions & 0 deletions src/Request/RequestHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@

interface RequestHeaders
{
/**
* @return array<string, string>
*/
public function getHeaders(): array;
}
11 changes: 11 additions & 0 deletions src/Request/RequestQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Scraper\Scraper\Request;

interface RequestQuery
{
/**
* @return array<string, string>
*/
public function getQuery(): array;
}

0 comments on commit 9967799

Please sign in to comment.