StreamParser::csv()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
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 14
			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 14
				if (is_array($value) || is_object($value)) {
27 14
					return (new Collection($value))->recursive();
28
				}
29 14
				return $value;
30 14
			});
31 25
		});
32 25
	}
33
34 11
	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 11
		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 10
	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 10
		return (new CSVParser())->from($source);
44
	}
45
}