Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
18 / 22
71.43% covered (warning)
71.43%
10 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 1
CrudTransactionResponse
81.82% covered (warning)
81.82%
18 / 22
71.43% covered (warning)
71.43%
10 / 14
19.95
0.00% covered (danger)
0.00%
0 / 1
 addCreated
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 addRead
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 addUpdated
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 addDeleted
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCreated
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCreated
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRead
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRead
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUpdated
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUpdated
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDeleted
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDeleted
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\WikispeechSpeechDataCollector\Crud\Transaction;
4
5/**
6 * @file
7 * @ingroup Extensions
8 * @license GPL-2.0-or-later
9 */
10
11use MediaWiki\WikispeechSpeechDataCollector\Domain\Persistent;
12
13/**
14 * @todo This is part of an internal development API. It should be removed before deployment.
15 *
16 * A collection of {@link Persistent} objects that have either
17 * been created, read, update or deleted via {@link CrudTransactionExecutor}.
18 *
19 * @since 0.1.0
20 */
21class CrudTransactionResponse {
22
23    /**
24     * @var mixed|null Client reference
25     * @see CrudTransactionRequest::$reference
26     */
27    private $reference;
28
29    /** @var array|null {@link Persistent} instances with no identity set */
30    private $created;
31
32    /** @var array|null {@link Persistent} instances */
33    private $read;
34
35    /** @var array|null {@link Persistent} instances */
36    private $updated;
37
38    /** @var array|null {@link Persistent} instances with identity only set */
39    private $deleted;
40
41    // Add-helpers
42
43    /** @param Persistent $instance */
44    public function addCreated( Persistent $instance ) {
45        if ( $this->created === null ) {
46            $this->created = [];
47        }
48        array_push( $this->created, $instance );
49    }
50
51    /** @param Persistent $instance */
52    public function addRead( Persistent $instance ) {
53        if ( $this->read === null ) {
54            $this->read = [];
55        }
56        array_push( $this->read, $instance );
57    }
58
59    /** @param Persistent $instance */
60    public function addUpdated( Persistent $instance ) {
61        if ( $this->updated === null ) {
62            $this->updated = [];
63        }
64        array_push( $this->updated, $instance );
65    }
66
67    /** @param Persistent $instance */
68    public function addDeleted( Persistent $instance ) {
69        if ( $this->deleted === null ) {
70            $this->deleted = [];
71        }
72        array_push( $this->deleted, $instance );
73    }
74
75    // Getters and setters
76
77    /**
78     * @return mixed|null
79     */
80    public function getReference() {
81        return $this->reference;
82    }
83
84    /**
85     * @param mixed|null $reference
86     */
87    public function setReference( $reference ): void {
88        $this->reference = $reference;
89    }
90
91    /**
92     * @return array|null
93     */
94    public function getCreated(): ?array {
95        return $this->created;
96    }
97
98    /**
99     * @param array|null $created
100     */
101    public function setCreated( ?array $created ): void {
102        $this->created = $created;
103    }
104
105    /**
106     * @return array|null
107     */
108    public function getRead(): ?array {
109        return $this->read;
110    }
111
112    /**
113     * @param array|null $read
114     */
115    public function setRead( ?array $read ): void {
116        $this->read = $read;
117    }
118
119    /**
120     * @return array|null
121     */
122    public function getUpdated(): ?array {
123        return $this->updated;
124    }
125
126    /**
127     * @param array|null $updated
128     */
129    public function setUpdated( ?array $updated ): void {
130        $this->updated = $updated;
131    }
132
133    /**
134     * @return array|null
135     */
136    public function getDeleted(): ?array {
137        return $this->deleted;
138    }
139
140    /**
141     * @param array|null $deleted
142     */
143    public function setDeleted( ?array $deleted ): void {
144        $this->deleted = $deleted;
145    }
146
147}