Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AbstractCompositePartMcrCrud
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 create
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\WikispeechSpeechDataCollector\Crud\Mcr;
4
5/**
6 * @file
7 * @ingroup Extensions
8 * @license GPL-2.0-or-later
9 */
10
11use ExternalStoreException;
12use MediaWiki\WikispeechSpeechDataCollector\Domain\Persistent;
13
14/**
15 * CRUD for composite association part objects.
16 *
17 * These are objects that require an existing composite owner object
18 * from which they inherit their identity.
19 *
20 * This means that there is a one-to-one relationship between all
21 * composite owner and composite part objects. Thus an intermediate
22 * relationship class is required in order to achieve a one-to-many
23 * relationship between an owner and a part.
24 *
25 * E.g, {@link Recording} would be a composite owner object,
26 * while {@link RecordingAnnotations} is a composite part object
27 * that depends on an existing Recording in order to be created.
28 * RecordingAnnotations contains a list of {@link RecordingAnnotation}
29 * in order to create the one-to-many relationship between
30 * Recording and RecordingAnnotation.
31 *
32 * @see AbstractCompositeOwnerMcrCrud
33 * @since 0.1.0
34 */
35abstract class AbstractCompositePartMcrCrud extends AbstractMcrCrud {
36
37    /**
38     * Asserts that identity is set.
39     *
40     * @param Persistent $instance
41     * @throws ExternalStoreException
42     */
43    public function create( Persistent $instance ): void {
44        if ( !$instance->getIdentity() ) {
45            throw new ExternalStoreException( 'Identity not set' );
46        }
47        parent::create( $instance );
48    }
49
50}