Issues (6)

src/StreamParser.php (3 issues)

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) {
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
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
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
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
}