ShariffService::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace CedricZiel\ShariffBundle\Service;
4
5
use CedricZiel\ShariffBundle\Model\ShariffConfig;
6
use GuzzleHttp\Exception\GuzzleException;
7
use Heise\Shariff\Backend;
8
9
/**
10
 * @package CedricZiel\ShariffBundle\Service
11
 */
12
class ShariffService implements ShariffServiceInterface
13
{
14
    /**
15
     * @var ShariffConfig
16
     */
17
    protected $config;
18
19
    /**
20
     * @param ShariffConfig $config
21
     */
22
    public function __construct(ShariffConfig $config)
23
    {
24
        $this->config = $config;
25
    }
26
27
    /**
28
     * Get the information from the backend for the given url
29
     *
30
     * @param string $url
31
     *
32
     * @return array
33
     */
34
    public function get($url)
35
    {
36
        $backend = new Backend($this->config->toArray());
37
38
        try {
39
            return $backend->get($url);
40
        } catch (GuzzleException $e) {
41
            return [$e];
42
        }
43
    }
44
}
45