• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / 18a2821b-9fed-4e27-8151-60c5375acb47

16 Aug 2024 11:47AM UTC coverage: 91.965% (-0.002%) from 91.967%
18a2821b-9fed-4e27-8151-60c5375acb47

push

circleci

aimeos
Removed unnecessary assignments in fromArray()

278 of 279 new or added lines in 40 files covered. (99.64%)

30 existing lines in 30 files now uncovered.

10244 of 11139 relevant lines covered (91.97%)

61.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.37
/src/MShop/Text/Item/Standard.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2024
7
 * @package MShop
8
 * @subpackage Text
9
 */
10

11

12
namespace Aimeos\MShop\Text\Item;
13

14

15
/**
16
 * Default text manager implementation.
17
 *
18
 * @package MShop
19
 * @subpackage Text
20
 */
21
class Standard
22
        extends \Aimeos\MShop\Common\Item\Base
23
        implements \Aimeos\MShop\Text\Item\Iface
24
{
25
        use \Aimeos\MShop\Common\Item\ListsRef\Traits;
26

27

28
        private ?string $langid;
29

30

31
        /**
32
         * Initializes the text item object with the given values.
33
         *
34
         * @param array $values Associative list of key/value pairs
35
         * @param \Aimeos\MShop\Common\Item\Lists\Iface[] $listItems List of list items
36
         * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items
37
         */
38
        public function __construct( array $values = [], array $listItems = [], array $refItems = [] )
39
        {
40
                parent::__construct( 'text.', $values );
98✔
41

42
                $this->langid = $values['.languageid'] ?? null;
98✔
43
                $this->initListItems( $listItems, $refItems );
98✔
44
        }
45

46

47
        /**
48
         * Returns the ISO language code.
49
         *
50
         * @return string|null ISO language code (e.g. de or de_DE)
51
         */
52
        public function getLanguageId() : ?string
53
        {
54
                return $this->get( 'text.languageid' );
37✔
55
        }
56

57

58
        /**
59
         * Sets the ISO language code.
60
         *
61
         * @param string|null $id ISO language code (e.g. de or de_DE)
62
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
63
         * @throws \Aimeos\MShop\Exception If the language ID is invalid
64
         */
65
        public function setLanguageId( ?string $id ) : \Aimeos\MShop\Text\Item\Iface
66
        {
67
                return $this->set( 'text.languageid', $this->checkLanguageId( $id ) );
3✔
68
        }
69

70

71
        /**
72
         * Returns the type of the text item.
73
         *
74
         * @return string Type of the text item
75
         */
76
        public function getType() : string
77
        {
78
                return $this->get( 'text.type', '' );
43✔
79
        }
80

81

82
        /**
83
         *  Sets the type of the text item.
84
         *
85
         * @param string $type Type of the text type
86
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
87
         */
88
        public function setType( string $type ) : \Aimeos\MShop\Common\Item\Iface
89
        {
90
                return $this->set( 'text.type', $this->checkCode( $type ) );
4✔
91
        }
92

93

94
        /**
95
         * Returns the domain of the text item.
96
         *
97
         * @return string Domain of the text item
98
         */
99
        public function getDomain() : string
100
        {
101
                return $this->get( 'text.domain', '' );
7✔
102
        }
103

104

105
        /**
106
         * Sets the domain of the text item.
107
         *
108
         * @param string $domain Domain of the text item
109
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
110
         */
111
        public function setDomain( string $domain ) : \Aimeos\MShop\Common\Item\Iface
112
        {
113
                return $this->set( 'text.domain', $domain );
6✔
114
        }
115

116

117
        /**
118
         * Returns the content of the text item.
119
         *
120
         * @return string Content of the text item
121
         */
122
        public function getContent() : string
123
        {
124
                return $this->get( 'text.content', '' );
36✔
125
        }
126

127

128
        /**
129
         * Sets the content of the text item.
130
         *
131
         * @param string $text Content of the text item
132
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
133
         */
134
        public function setContent( string $text ) : \Aimeos\MShop\Text\Item\Iface
135
        {
136
                ini_set( 'mbstring.substitute_character', 'none' );
24✔
137
                return $this->set( 'text.content', @mb_convert_encoding( $text, 'UTF-8', 'UTF-8' ) );
24✔
138
        }
139

140

141
        /**
142
         * Returns the name of the attribute item.
143
         *
144
         * @return string Label of the attribute item
145
         */
146
        public function getLabel() : string
147
        {
148
                return $this->get( 'text.label', '' );
7✔
149
        }
150

151

152
        /**
153
         * Sets the new label of the attribute item.
154
         *
155
         * @param string $label Type label of the attribute item
156
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
157
         */
158
        public function setLabel( ?string $label ) : \Aimeos\MShop\Text\Item\Iface
159
        {
160
                return $this->set( 'text.label', (string) $label );
3✔
161
        }
162

163

164
        /**
165
         * Returns the status of the text item.
166
         *
167
         * @return int Status of the text item
168
         */
169
        public function getStatus() : int
170
        {
171
                return $this->get( 'text.status', 1 );
44✔
172
        }
173

174

175
        /**
176
         * Sets the status of the text item.
177
         *
178
         * @param int $status true/false for enabled/disabled
179
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
180
         */
181
        public function setStatus( int $status ) : \Aimeos\MShop\Common\Item\Iface
182
        {
183
                return $this->set( 'text.status', $status );
24✔
184
        }
185

186

187
        /**
188
         * Tests if the item is available based on status, time, language and currency
189
         *
190
         * @return bool True if available, false if not
191
         */
192
        public function isAvailable() : bool
193
        {
194
                return parent::isAvailable() && $this->getStatus() > 0
37✔
195
                        && ( $this->langid === null || $this->getLanguageId() === null
37✔
196
                        || $this->getLanguageId() === $this->langid );
37✔
197
        }
198

199

200
        /**
201
         * Sets the item values from the given array and removes that entries from the list
202
         *
203
         * @param array &$list Associative list of item keys and their values
204
         * @param bool True to set private properties too, false for public only
205
         * @return \Aimeos\MShop\Text\Item\Iface Text item for chaining method calls
206
         */
207
        public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface
208
        {
209
                $item = parent::fromArray( $list, $private );
1✔
210

211
                foreach( $list as $key => $value )
1✔
212
                {
213
                        switch( $key )
214
                        {
215
                                case 'text.languageid': $item->setLanguageId( $value ); break;
1✔
216
                                case 'text.type': $item->setType( $value ); break;
1✔
217
                                case 'text.label': $item->setLabel( $value ); break;
1✔
218
                                case 'text.domain': $item->setDomain( $value ); break;
1✔
219
                                case 'text.content': $item->setContent( $value ); break;
1✔
220
                                case 'text.status': $item->setStatus( (int) $value ); break;
1✔
UNCOV
221
                                default: continue 2;
×
222
                        }
223

224
                        unset( $list[$key] );
1✔
225
                }
226

227
                return $item;
1✔
228
        }
229

230

231
        /**
232
         * Returns the item values as array.
233
         *
234
         * @param bool True to return private properties, false for public only
235
         * @return array Associative list of item properties and their values
236
         */
237
        public function toArray( bool $private = false ) : array
238
        {
239
                $list = parent::toArray( $private );
1✔
240

241
                $list['text.languageid'] = $this->getLanguageId();
1✔
242
                $list['text.type'] = $this->getType();
1✔
243
                $list['text.label'] = $this->getLabel();
1✔
244
                $list['text.domain'] = $this->getDomain();
1✔
245
                $list['text.content'] = $this->getContent();
1✔
246
                $list['text.status'] = $this->getStatus();
1✔
247

248
                return $list;
1✔
249
        }
250
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc