Issues (13)

src/Esa/Proxy.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Esa;
6
7
use Polidog\Esa\Api;
8
use Symfony\Contracts\Cache\CacheInterface;
9
use Symfony\Contracts\Cache\ItemInterface;
10
11
/**
12
 * @see https://docs.esa.io/posts/102
13
 */
14
class Proxy
15
{
16
    public const CACHE_KEY_PREFIX = 'esaba.esa.proxy';
17
18 4
    public function __construct(private Api $api, private CacheInterface $cache)
19
    {
20
    }
21
22 3
    public function getPost(int $postId, bool $force = false): array
23
    {
24 3
        $cacheKey = sprintf('%s.post.%d', self::CACHE_KEY_PREFIX, $postId);
25
26 3
        if ($force) {
27 3
            $this->cache->delete($cacheKey);
28
        }
29
30 3
        $post = $this->cache->get($cacheKey, function (ItemInterface $item) use ($postId) {
0 ignored issues
show
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
        $post = $this->cache->get($cacheKey, function (/** @scrutinizer ignore-unused */ ItemInterface $item) use ($postId) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31 2
            return $this->api->post($postId);
32
        });
33
34 3
        return $post;
35
    }
36
37 2
    public function getEmojis(): array
38
    {
39 2
        $cacheKey = sprintf('%s.emojis', self::CACHE_KEY_PREFIX);
40
41 2
        $emojis = $this->cache->get($cacheKey, function (ItemInterface $item) {
0 ignored issues
show
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
        $emojis = $this->cache->get($cacheKey, function (/** @scrutinizer ignore-unused */ ItemInterface $item) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42 1
            return $this->api->emojis(['include' => 'all'])['emojis'];
43
        });
44
45 2
        return $emojis;
46
    }
47
}
48