helpers.php ➔ factory()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 3
nop 0
dl 0
loc 15
rs 9.4555
c 0
b 0
f 0
1
<?php
2
3
use Faker\Factory;
4
use Phalcon\Debug\Dump;
5
use Yarak\DB\Factories\ModelFactory;
6
7
if (!function_exists('factory')) {
8
    /**
9
     * Dump the passed variables and end the script.
10
     *
11
     * @param  mixed
12
     */
13
    function factory()
14
    {
15
        $factory = new ModelFactory(Factory::create());
16
17
        $arguments = func_get_args();
18
19
        if (isset($arguments[1]) && is_string($arguments[1])) {
20
            return $factory->forClass($arguments[0], $arguments[1])
21
                ->times(isset($arguments[2]) ? $arguments[2] : null);
22
        } elseif (isset($arguments[1])) {
23
            return $factory->forClass($arguments[0])->times($arguments[1]);
24
        }
25
26
        return $factory->forClass($arguments[0]);
27
    }
28
}
29