Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump aglipanci/laravel-pint-action from 1.0.0 to 2.3.1 #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@1.0.0
uses: aglipanci/laravel-pint-action@2.3.1

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
14 changes: 9 additions & 5 deletions src/EnergyZero.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
namespace Baspa\EnergyZero;

use DateTime;
use Exception;
use DateTimeZone;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;

class EnergyZero
{
private bool $vat = true;

private int $requestTimeout = 10;

private string $baseUri = 'https://api.energyzero.nl/v1/';

private ClientInterface $client;

public function __construct(ClientInterface $client = null)
public function __construct(?ClientInterface $client = null)
{
$this->client = $client ?? new Client([
'base_uri' => $this->baseUri,
Expand All @@ -42,10 +45,11 @@ public function request(string $uri, array $params = []): ?array
if ($response->getStatusCode() === 200) {
return json_decode($response->getBody()->getContents(), true);
} else {
throw new Exception('Unexpected response status: ' . $response->getStatusCode());
throw new Exception('Unexpected response status: '.$response->getStatusCode());
}
} catch (RequestException $e) {
error_log('Error: ' . $e->getMessage());
error_log('Error: '.$e->getMessage());

return null;
}
}
Expand Down Expand Up @@ -192,4 +196,4 @@ public function getValleyHours(string $startDate, string $endDate, int $topN = 5

return array_slice($prices, 0, $topN);
}
}
}
4 changes: 2 additions & 2 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use GuzzleHttp\Psr7\Response;

beforeEach(function () {
$this->mockHandler = new MockHandler();
$this->mockHandler = new MockHandler;
$handlerStack = HandlerStack::create($this->mockHandler);
$client = new Client(['handler' => $handlerStack]);
$this->energyZero = new EnergyZero($client);
Expand Down Expand Up @@ -171,4 +171,4 @@
['readingDate' => '2023-05-01T00:00:00', 'price' => 0.1],
['readingDate' => '2023-05-01T02:00:00', 'price' => 0.2],
]);
});
});