Conditions | 6 |
Paths | 20 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
46 | public function create($url) |
||
47 | { |
||
48 | if (is_string($url)) { |
||
49 | $url = Url::parse($url); |
||
50 | } |
||
51 | |||
52 | if (is_array($url)) { |
||
53 | $url = Url::import($url); |
||
54 | } |
||
55 | |||
56 | if (!$url instanceof Url) { |
||
57 | throw new \InvalidArgumentException(sprintf('URL should be a string, an array or an instance of Url class')); |
||
58 | } |
||
59 | |||
60 | $io = new StreamIO(); |
||
61 | |||
62 | if ($this->logger) { |
||
63 | $io = new LoggerDecoratedIO($io, $this->logger); |
||
64 | } |
||
65 | |||
66 | $wire = new Wire($io); |
||
67 | |||
68 | if ($this->logger) { |
||
69 | $wire = new LoggerDecoratedWire($wire, $this->logger); |
||
70 | } |
||
71 | |||
72 | return new Connection($url, $wire); |
||
73 | } |
||
74 | } |
||
75 |