Skip to content

Commit

Permalink
Merge pull request #9 from openfoodfacts/deepsource-transform-b76bdb88
Browse files Browse the repository at this point in the history
fix: Format code with php-cs-fixer
  • Loading branch information
epalmans committed Feb 8, 2022
2 parents 597d844 + dff16c6 commit 2b8c5f2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/OpenFoodFacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function find($searchterm)
$pages = (int)ceil($totalMatches / $pageResults->getPageSize());

$products = $products->concat(iterator_to_array($pageResults));

} while ($page < $pages);

return $products->map(function ($product) {
Expand Down
82 changes: 41 additions & 41 deletions src/OpenFoodFactsApiWrapper.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<?php

namespace OpenFoodFacts\Laravel;

use GuzzleHttp\Client;
use OpenFoodFacts\Api;
use Psr\SimpleCache\CacheInterface;

class OpenFoodFactsApiWrapper
{
protected $parameters;
protected $cache;

public $api;

public function __construct(array $parameters, CacheInterface $cache = null)
{
$this->parameters = $parameters;
$this->cache = $cache;

$this->api = $this->setupApi();
}

protected function setupApi($environment = 'food')
{
return new Api(
$environment,
$this->parameters['geography'] ?? 'world',
null,
$this->httpClient(),
$this->cache
);
}

protected function httpClient()
{
return new Client([
'headers' => ['User-Agent' => $this->parameters['app'] ?? 'Laravel Open Food Facts - https://github.com/openfoodfacts/openfoodfacts-laravel'],
]);
}
}
<?php

namespace OpenFoodFacts\Laravel;

use GuzzleHttp\Client;
use OpenFoodFacts\Api;
use Psr\SimpleCache\CacheInterface;

class OpenFoodFactsApiWrapper
{
protected $parameters;
protected $cache;

public $api;

public function __construct(array $parameters, CacheInterface $cache = null)
{
$this->parameters = $parameters;
$this->cache = $cache;

$this->api = $this->setupApi();
}

protected function setupApi($environment = 'food')
{
return new Api(
$environment,
$this->parameters['geography'] ?? 'world',
null,
$this->httpClient(),
$this->cache
);
}

protected function httpClient()
{
return new Client([
'headers' => ['User-Agent' => $this->parameters['app'] ?? 'Laravel Open Food Facts - https://github.com/openfoodfacts/openfoodfacts-laravel'],
]);
}
}
28 changes: 14 additions & 14 deletions tests/Base/FacadeTestCase.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace OpenFoodFacts\Laravel\Tests\Base;

use Orchestra\Testbench\TestCase;
use OpenFoodFacts\Laravel\OpenFoodFactsServiceProvider;

abstract class FacadeTestCase extends TestCase
{
protected function getPackageProviders($app)
{
return [OpenFoodFactsServiceProvider::class];
}
}
<?php

namespace OpenFoodFacts\Laravel\Tests\Base;

use Orchestra\Testbench\TestCase;
use OpenFoodFacts\Laravel\OpenFoodFactsServiceProvider;

abstract class FacadeTestCase extends TestCase
{
protected function getPackageProviders($app)
{
return [OpenFoodFactsServiceProvider::class];
}
}
2 changes: 1 addition & 1 deletion tests/ProductSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function it_returns_a_laravelcollection_with_arrays()

$this->assertTrue($results->isNotEmpty());

$results->each(function($arr) {
$results->each(function ($arr) {
$this->assertIsArray($arr);
});
}
Expand Down

0 comments on commit 2b8c5f2

Please sign in to comment.