Passed
Pull Request — master (#1)
by Kevin
03:05
created

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