Passed
Push — master ( 1ed9d2...698c63 )
by Sergio
01:13
created

StreamParser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A xml() 0 2 1
A csv() 0 2 1
A json() 0 2 1
A __construct() 0 8 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sergio.rodenas
5
 * Date: 12/5/18
6
 * Time: 0:00
7
 */
8
9
namespace Rodenastyle\StreamParser;
10
11
12
use Rodenastyle\StreamParser\Parsers\CSVParser;
13
use Rodenastyle\StreamParser\Parsers\JSONParser;
14
use Rodenastyle\StreamParser\Parsers\XMLParser;
15
use Rodenastyle\StreamParser\Traits\Facade;
16
use Tightenco\Collect\Support\Collection;
17
18
class StreamParser
19
{
20
	use Facade;
21
22
	private function __construct()
23
	{
24
		Collection::macro('recursive', function () {
25 9
			return $this->map(function ($value) {
0 ignored issues
show
Bug introduced by
The method map() does not exist on Rodenastyle\StreamParser\StreamParser. ( Ignorable by Annotation )

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

25
			return $this->/** @scrutinizer ignore-call */ map(function ($value) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26 9
				if (is_array($value) || is_object($value)) {
27 9
					return (new Collection($value))->recursive();
28
				}
29 9
				return $value;
30 9
			});
31 15
		});
32 15
	}
33
34 6
	private function xml(String $source){
0 ignored issues
show
Unused Code introduced by
The method xml() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
35 6
		return (new XMLParser())->from($source);
36
	}
37
38 4
	private function json(String $source){
0 ignored issues
show
Unused Code introduced by
The method json() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
39 4
		return (new JSONParser())->from($source);
40
	}
41
42 5
	private function csv(String $source){
0 ignored issues
show
Unused Code introduced by
The method csv() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
43 5
		return (new CSVParser())->from($source);
44
	}
45
}