Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AbstractCrud | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
instanceFactory | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
read | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\WikispeechSpeechDataCollector\Crud; |
4 | |
5 | /** |
6 | * @file |
7 | * @ingroup Extensions |
8 | * @license GPL-2.0-or-later |
9 | */ |
10 | |
11 | use MediaWiki\WikispeechSpeechDataCollector\Domain\Persistent; |
12 | |
13 | /** |
14 | * Abstract access for instances of the corresponding underlying subclass of {@link Persistent}. |
15 | * |
16 | * @since 0.1.0 |
17 | */ |
18 | abstract class AbstractCrud implements Crud { |
19 | |
20 | /** @var CrudContext */ |
21 | private $context; |
22 | |
23 | /** |
24 | * @param CrudContext $context |
25 | * @since 0.1.0 |
26 | */ |
27 | public function __construct( CrudContext $context ) { |
28 | $this->context = $context; |
29 | } |
30 | |
31 | /** |
32 | * @return CrudContext |
33 | * @since 0.1.0 |
34 | */ |
35 | public function getContext(): CrudContext { |
36 | return $this->context; |
37 | } |
38 | |
39 | /** |
40 | * Creates a new instance |
41 | * of the corresponding underlying subclass of {@link Persistent}. |
42 | * |
43 | * @return Persistent |
44 | * @since 0.1.0 |
45 | */ |
46 | abstract public function instanceFactory(): Persistent; |
47 | |
48 | /** |
49 | * Given an identity, |
50 | * retrieves a persistent domain object from the database. |
51 | * |
52 | * @see load() |
53 | * @param mixed $identity |
54 | * @return Persistent|null |
55 | * @since 0.1.0 |
56 | */ |
57 | public function read( |
58 | $identity |
59 | ): ?Persistent { |
60 | $instance = $this->instanceFactory(); |
61 | $instance->setIdentity( $identity ); |
62 | return $this->load( $instance ) ? $instance : null; |
63 | } |
64 | } |