-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from openfoodfacts/deepsource-transform-b76bdb88
fix: Format code with php-cs-fixer
- Loading branch information
Showing
4 changed files
with
56 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters