Code Duplication    Length = 18-18 lines in 4 locations

src/Subjects/AbstractCategorySubject.php 2 locations

@@ 350-367 (lines=18) @@
347
     * @return integer The store website ID
348
     * @throws \Exception Is thrown, if the store website with the requested code is not available
349
     */
350
    public function getStoreWebsiteIdByCode($code)
351
    {
352
353
        // query whether or not, the requested store website is available
354
        if (isset($this->storeWebsites[$code])) {
355
            return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID];
356
        }
357
358
        // throw an exception, if not
359
        throw new \Exception(
360
            sprintf(
361
                'Found invalid website code %s in file %s on line %d',
362
                $code,
363
                $this->getFilename(),
364
                $this->getLineNumber()
365
            )
366
        );
367
    }
368
369
    /**
370
     * Return's the category with the passed path.
@@ 377-394 (lines=18) @@
374
     * @return array The category
375
     * @throws \Exception Is thrown, if the requested category is not available
376
     */
377
    public function getCategoryByPath($path)
378
    {
379
380
        // query whether or not the category with the passed path exists
381
        if (isset($this->categories[$path])) {
382
            return $this->categories[$path];
383
        }
384
385
        // throw an exception, if not
386
        throw new \Exception(
387
            sprintf(
388
                'Can\'t find category with path %s in file %s on line %d',
389
                $path,
390
                $this->getFilename(),
391
                $this->getLineNumber()
392
            )
393
        );
394
    }
395
396
    /**
397
     * Add the passed category to the available categories.

src/Subjects/BunchSubject.php 2 locations

@@ 165-182 (lines=18) @@
162
     * @return integer The requested display mode
163
     * @throws \Exception Is thrown, if the requested display mode is not available
164
     */
165
    public function getDisplayModeByValue($displayMode)
166
    {
167
168
        // query whether or not, the requested display mode is available
169
        if (isset($this->availableDisplayModes[$displayMode])) {
170
            return $this->availableDisplayModes[$displayMode];
171
        }
172
173
        // throw an exception, if not
174
        throw new \Exception(
175
            sprintf(
176
                'Found invalid display mode %s in file %s on line %d',
177
                $visibility,
178
                $this->getFilename(),
179
                $this->getLineNumber()
180
            )
181
        );
182
    }
183
184
    /**
185
     * Return's the page layout for the passed page layout string.
@@ 192-209 (lines=18) @@
189
     * @return integer The requested page layout
190
     * @throws \Exception Is thrown, if the requested page layout is not available
191
     */
192
    public function getPageLayoutByValue($pageLayout)
193
    {
194
195
        // query whether or not, the requested display mode is available
196
        if (isset($this->availablePageLayouts[$pageLayout])) {
197
            return $this->availablePageLayouts[$pageLayout];
198
        }
199
200
        // throw an exception, if not
201
        throw new \Exception(
202
            sprintf(
203
                'Found invalid page layout %s in file %s on line %d',
204
                $visibility,
205
                $this->getFilename(),
206
                $this->getLineNumber()
207
            )
208
        );
209
    }
210
211
    /**
212
     * Cast's the passed value based on the backend type information.