Completed
Push — master ( bf2650...6b9cb3 )
by Greg
06:18
created

Factory::location()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2020 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees;
21
22
use Fisharebest\Webtrees\Contracts\FamilyFactoryInterface;
23
use Fisharebest\Webtrees\Contracts\GedcomRecordFactoryInterface;
24
use Fisharebest\Webtrees\Contracts\HeaderFactoryInterface;
25
use Fisharebest\Webtrees\Contracts\IndividualFactoryInterface;
26
use Fisharebest\Webtrees\Contracts\LocationFactoryInterface;
27
use Fisharebest\Webtrees\Contracts\MediaFactoryInterface;
28
use Fisharebest\Webtrees\Contracts\NoteFactoryInterface;
29
use Fisharebest\Webtrees\Contracts\RepositoryFactoryInterface;
30
use Fisharebest\Webtrees\Contracts\SourceFactoryInterface;
31
use Fisharebest\Webtrees\Contracts\SubmissionFactoryInterface;
32
use Fisharebest\Webtrees\Contracts\SubmitterFactoryInterface;
33
use Fisharebest\Webtrees\Contracts\XrefFactoryInterface;
34
35
/**
36
 * A service locator for our various factory objects.
37
 *
38
 * @deprecated - will be removed in 2.1.0 - use Registry instead.
39
 */
40
class Factory
41
{
42
    /**
43
     * Store or retrieve a factory object.
44
     *
45
     * @param FamilyFactoryInterface|null $factory
46
     *
47
     * @return FamilyFactoryInterface
48
     */
49
    public static function family(FamilyFactoryInterface $factory = null): FamilyFactoryInterface
50
    {
51
        return Registry::familyFactory($factory);
52
    }
53
54
    /**
55
     * Store or retrieve a factory object.
56
     *
57
     * @param GedcomRecordFactoryInterface|null $factory
58
     *
59
     * @return GedcomRecordFactoryInterface
60
     */
61
    public static function gedcomRecord(GedcomRecordFactoryInterface $factory = null): GedcomRecordFactoryInterface
62
    {
63
        return Registry::gedcomRecordFactory($factory);
64
    }
65
66
    /**
67
     * Store or retrieve a factory object.
68
     *
69
     * @param HeaderFactoryInterface|null $factory
70
     *
71
     * @return HeaderFactoryInterface
72
     */
73
    public static function header(HeaderFactoryInterface $factory = null): HeaderFactoryInterface
74
    {
75
        return Registry::headerFactory($factory);
76
    }
77
78
    /**
79
     * Store or retrieve a factory object.
80
     *
81
     * @param IndividualFactoryInterface|null $factory
82
     *
83
     * @return IndividualFactoryInterface
84
     */
85
    public static function individual(IndividualFactoryInterface $factory = null): IndividualFactoryInterface
86
    {
87
        return Registry::individualFactory($factory);
88
    }
89
90
    /**
91
     * Store or retrieve a factory object.
92
     *
93
     * @param LocationFactoryInterface|null $factory
94
     *
95
     * @return LocationFactoryInterface
96
     */
97
    public static function location(LocationFactoryInterface $factory = null): LocationFactoryInterface
98
    {
99
        return Registry::locationFactory($factory);
100
    }
101
102
    /**
103
     * Store or retrieve a factory object.
104
     *
105
     * @param MediaFactoryInterface|null $factory
106
     *
107
     * @return MediaFactoryInterface
108
     */
109
    public static function media(MediaFactoryInterface $factory = null): MediaFactoryInterface
110
    {
111
        return Registry::mediaFactory($factory);
112
    }
113
114
    /**
115
     * Store or retrieve a factory object.
116
     *
117
     * @param NoteFactoryInterface|null $factory
118
     *
119
     * @return NoteFactoryInterface
120
     */
121
    public static function note(NoteFactoryInterface $factory = null): NoteFactoryInterface
122
    {
123
        return Registry::noteFactory($factory);
124
    }
125
126
    /**
127
     * Store or retrieve a factory object.
128
     *
129
     * @param RepositoryFactoryInterface|null $factory
130
     *
131
     * @return RepositoryFactoryInterface
132
     */
133
    public static function repository(RepositoryFactoryInterface $factory = null): RepositoryFactoryInterface
134
    {
135
        return Registry::repositoryFactory($factory);
136
    }
137
138
    /**
139
     * Store or retrieve a factory object.
140
     *
141
     * @param SourceFactoryInterface|null $factory
142
     *
143
     * @return SourceFactoryInterface
144
     */
145
    public static function source(SourceFactoryInterface $factory = null): SourceFactoryInterface
146
    {
147
        return Registry::sourceFactory($factory);
148
    }
149
150
    /**
151
     * Store or retrieve a factory object.
152
     *
153
     * @param SubmissionFactoryInterface|null $factory
154
     *
155
     * @return SubmissionFactoryInterface
156
     */
157
    public static function submission(SubmissionFactoryInterface $factory = null): SubmissionFactoryInterface
158
    {
159
        return Registry::submissionFactory($factory);
160
    }
161
162
    /**
163
     * Store or retrieve a factory object.
164
     *
165
     * @param SubmitterFactoryInterface|null $factory
166
     *
167
     * @return SubmitterFactoryInterface
168
     */
169
    public static function submitter(SubmitterFactoryInterface $factory = null): SubmitterFactoryInterface
170
    {
171
        return Registry::submitterFactory($factory);
172
    }
173
174
    /**
175
     * Store or retrieve a factory object.
176
     *
177
     * @param XrefFactoryInterface|null $factory
178
     *
179
     * @return XrefFactoryInterface
180
     */
181
    public static function xref(XrefFactoryInterface $factory = null): XrefFactoryInterface
182
    {
183
        return Registry::xrefFactory($factory);
184
    }
185
}
186