Completed
Push — master ( ac0544...a10425 )
by Nate
11:46 queued 42s
created

Factory::simpleItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
crap 2
1
<?php
2
3
/**
4
 * @author    Flipbox Factory
5
 * @copyright Copyright (c) 2017, Flipbox Digital
6
 * @link      https://github.com/flipbox/transform/releases/latest
7
 * @license   https://github.com/flipbox/transform/blob/master/LICENSE
8
 */
9
10
namespace Flipbox\Transform;
11
12
use Flipbox\Transform\Resources\SimpleCollection;
13
use Flipbox\Transform\Resources\SimpleItem;
14
use Flipbox\Transform\Transformers\TransformerInterface;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class Factory
21
{
22
    /**
23
     * @param callable|TransformerInterface $transformer
24
     * @param $data
25
     * @param array $extra
26
     * @return array|null
27
     */
28
    public static function simpleCollection(callable $transformer, $data, array $extra = [])
29
    {
30
        return call_user_func_array(new SimpleCollection(), [$data, $transformer, $extra]);
31
    }
32
33
    /**
34
     * @param callable|TransformerInterface $transformer
35
     * @param $data
36
     * @param array $extra
37
     * @return array|null
38
     */
39
    public static function simpleItem(callable $transformer, $data, array $extra = [])
40
    {
41
        return call_user_func_array(new SimpleItem(), [$data, $transformer, $extra]);
42
    }
43
44
    /**
45
     * @param callable|TransformerInterface $transformer
46
     * @param $data
47
     * @param array $config
48
     * @param array $extra
49
     * @return array|null
50
     */
51
    public static function collection(callable $transformer, $data, array $config = [], array $extra = [])
52
    {
53
        return self::transform($config)->collection($transformer, $data, $extra);
54
    }
55
56
    /**
57
     * @param callable|TransformerInterface $transformer
58
     * @param $data
59
     * @param array $config
60
     * @param array $extra
61
     * @return array|null
62
     */
63
    public static function item(callable $transformer, $data, array $config = [], array $extra = [])
64
    {
65
        return self::transform($config)->item($transformer, $data, $extra);
66
    }
67
68
    /**
69
     * @param array $config
70
     * @return Transform
71
     */
72
    public static function transform(array $config = []): Transform
73
    {
74
        return new Transform($config);
75
    }
76
}
77