ShariffService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 10 2
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