Passed
Pull Request — master (#1)
by Kevin
02:18
created

create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 1
cts 1
cp 1
crap 1
1
<?php
2
3
namespace Zenstruck\Foundry;
4
5
use Doctrine\Persistence\ObjectRepository;
6
use Faker;
7
8
/**
9
 * @see Factory::__construct()
10
 */
11
function factory(string $class, $defaultAttributes = []): Factory
12
{
13 8
    return new Factory($class, $defaultAttributes);
14
}
15
16
/**
17
 * @see Factory::create()
18
 *
19
 * @return Proxy|object
20
 */
21
function create(string $class, $attributes = [], ?bool $proxy = null): object
22
{
23 2
    return factory($class)->create($attributes, $proxy);
24
}
25
26
/**
27
 * @see Factory::createMany()
28
 *
29
 * @return Proxy[]|object[]
30
 */
31
function create_many(int $number, string $class, $attributes = [], ?bool $proxy = null): array
32
{
33 2
    return factory($class)->createMany($number, $attributes, $proxy);
34
}
35
36
/**
37
 * @see Factory::instantiate()
38
 */
39
function instantiate(string $class, $attributes = []): object
40
{
41 2
    return factory($class)->instantiate($attributes);
42
}
43
44
/**
45
 * @see Factory::instantiateMany()
46
 */
47
function instantiate_many(int $number, string $class, $attributes = []): array
48
{
49 2
    return factory($class)->instantiateMany($number, $attributes);
50
}
51
52
/**
53
 * @see PersistenceManager::repositoryFor()
54
 *
55
 * @return RepositoryProxy|ObjectRepository
56
 */
57
function repository($objectOrClass, bool $proxy = true): ObjectRepository
58
{
59 10
    return PersistenceManager::repositoryFor($objectOrClass, $proxy);
60
}
61
62
/**
63
 * @see Factory::faker()
64
 */
65
function faker(): Faker\Generator
66
{
67 2
    return Factory::faker();
68
}
69