| Total Complexity | 6 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Proxy |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Client |
||
| 12 | */ |
||
| 13 | private $client; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var Cache |
||
| 17 | */ |
||
| 18 | private $cache; |
||
| 19 | |||
| 20 | const CACHE_KEY_PREFIX = 'ttskch.esa.proxy.'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param Client $client |
||
| 24 | * @param Cache $cache |
||
| 25 | */ |
||
| 26 | public function __construct(Client $client, Cache $cache) |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param int $postId |
||
| 34 | * @param bool $force |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | public function getPost($postId, $force = false) |
||
| 38 | { |
||
| 39 | $cacheKey = sprintf('%s.post.%d', self::CACHE_KEY_PREFIX, $postId); |
||
| 40 | |||
| 41 | if (!$force && $post = $this->cache->fetch($cacheKey)) { |
||
| 42 | return $post; |
||
| 43 | } |
||
| 44 | |||
| 45 | $post = $this->client->post($postId); |
||
| 46 | $this->cache->save($cacheKey, $post); |
||
| 47 | |||
| 48 | return $post; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return array |
||
| 53 | */ |
||
| 54 | public function getEmojis() |
||
| 66 | } |
||
| 67 | } |
||
| 68 |