for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Class ApiResultLoader
*/
namespace HDNET\OnpageIntegration\Loader;
use HDNET\OnpageIntegration\Exception\ApiErrorException;
use HDNET\OnpageIntegration\Persister\ApiResultToCachePersister;
use HDNET\OnpageIntegration\Service\DataService;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ApiResultLoader
{
* @var \HDNET\OnpageIntegration\Service\DataService
protected $dataService;
* @var \HDNET\OnpageIntegration\Persister\ApiResultToCachePersister
protected $persister;
* ApiResultLoader constructor.
*
* @param \HDNET\OnpageIntegration\Service\DataService $dataService
* @param \HDNET\OnpageIntegration\Persister\ApiResultToCachePersister $apiResultToCachePersister
public function __construct(DataService $dataService, ApiResultToCachePersister $apiResultToCachePersister)
$this->dataService = $dataService;
$this->persister = $apiResultToCachePersister;
}
* @param string $key
* @return array
public function load($key)
$cacheId = $this->persister->getIdentifier($key);
$entry = GeneralUtility::makeInstance(CacheManager::class)
->getCache('onpage_extension')
->get($cacheId);
if ($entry === false) {
try {
$entry = $this->dataService->getApiResult($key);
} catch (ApiErrorException $e) {
$this->persister->persist($entry, $key);
$entry
array
string
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return json_decode($entry, true);