Skip to content

Commit

Permalink
feat: class to call
Browse files Browse the repository at this point in the history
  • Loading branch information
npldevfr committed Jan 30, 2024
1 parent c5b3d4c commit daf272f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 100 deletions.
24 changes: 24 additions & 0 deletions src/Interfaces/LiquipediaBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Npldevfr\Liquipedia\Interfaces;

interface LiquipediaBuilderInterface
{
public function wiki(array|string $wikis): self;

public function endpoint(string $endpoint): self;

public function rawConditions(string $conditions): self;

public function limit(int $limit): self;

public function get(): array;

public function addWiki(string $wikis): self;

public function offset(int $offset): self;

public function orderBy(string $orderBy): self;


}
5 changes: 2 additions & 3 deletions src/Liquipedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
?LiquipediaBuilder $builder = null
) {

if ($apiKey === '' || $apiKey === '0') {
if ($apiKey === ''){
throw new \InvalidArgumentException('[Liquipedia] Api key is required');
}

Expand All @@ -35,7 +35,6 @@ public function __construct(

public function query(array $params = [], ?QueryParameters $queryParameters = null, ?Client $client = null): LiquipediaBuilder
{

return (new self($this->apiKey))->builder->query($params, $queryParameters, $client);
return (new self($this->apiKey))->builder;
}
}
12 changes: 3 additions & 9 deletions src/LiquipediaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use JsonException;
use Npldevfr\Liquipedia\Interfaces\LiquipediaBuilderInterface;
use Npldevfr\Liquipedia\Meta\Endpoint;
use Npldevfr\Liquipedia\Meta\SortOrder;
use Npldevfr\Liquipedia\Query\QueryBuilder;
use Npldevfr\Liquipedia\Query\QueryParameters;

final class LiquipediaBuilder extends QueryBuilder
final class LiquipediaBuilder extends QueryBuilder implements LiquipediaBuilderInterface
{
private string $endpoint;

Expand All @@ -25,13 +26,6 @@ public function __construct(
parent::__construct($params, $queryParameters, $client);
}

/**
* @param array<string> $params
*/
public static function query(array $params = [], ?QueryParameters $queryParameters = null, ?Client $client = null): self
{
return new self($params, $queryParameters, $client);
}

/**
* Set the wikis you want to query. You can pass an array of wikis or a string.
Expand Down Expand Up @@ -266,7 +260,6 @@ private function avoidWikiDuplicates(): void
public function get(?string $endpoint = null): array
{

dd($this->client->getConfig());

$customEndpoint = $endpoint ?? $this->endpoint;
$response = json_decode($this->client->get($customEndpoint, [
Expand All @@ -277,6 +270,7 @@ public function get(?string $endpoint = null): array
throw new Exception($response->error);
}


// $this->queryParameters = new QueryParameters();
return $response->result ?? [];
}
Expand Down
Loading

0 comments on commit daf272f

Please sign in to comment.