Code Duplication    Length = 18-18 lines in 4 locations

src/Subjects/AbstractProductSubject.php 3 locations

@@ 412-429 (lines=18) @@
409
     * @return integer The tax class ID
410
     * @throws \Exception Is thrown, if the tax class with the requested name is not available
411
     */
412
    public function getTaxClassIdByTaxClassName($taxClassName)
413
    {
414
415
        // query whether or not, the requested tax class is available
416
        if (isset($this->taxClasses[$taxClassName])) {
417
            return (integer) $this->taxClasses[$taxClassName][MemberNames::CLASS_ID];
418
        }
419
420
        // throw an exception, if not
421
        throw new \Exception(
422
            sprintf(
423
                'Found invalid tax class name %s in file %s on line %d',
424
                $taxClassName,
425
                $this->getFilename(),
426
                $this->getLineNumber()
427
            )
428
        );
429
    }
430
431
    /**
432
     * Return's the store website for the passed code.
@@ 439-456 (lines=18) @@
436
     * @return integer The store website ID
437
     * @throws \Exception Is thrown, if the store website with the requested code is not available
438
     */
439
    public function getStoreWebsiteIdByCode($code)
440
    {
441
442
        // query whether or not, the requested store website is available
443
        if (isset($this->storeWebsites[$code])) {
444
            return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID];
445
        }
446
447
        // throw an exception, if not
448
        throw new \Exception(
449
            sprintf(
450
                'Found invalid website code %s in file %s on line %d',
451
                $code,
452
                $this->getFilename(),
453
                $this->getLineNumber()
454
            )
455
        );
456
    }
457
458
    /**
459
     * Return's the category with the passed path.
@@ 466-483 (lines=18) @@
463
     * @return array The category
464
     * @throws \Exception Is thrown, if the requested category is not available
465
     */
466
    public function getCategoryByPath($path)
467
    {
468
469
        // query whether or not the category with the passed path exists
470
        if (isset($this->categories[$path])) {
471
            return $this->categories[$path];
472
        }
473
474
        // throw an exception, if not
475
        throw new \Exception(
476
            sprintf(
477
                'Can\'t find category with path %s in file %s on line %d',
478
                $path,
479
                $this->getFilename(),
480
                $this->getLineNumber()
481
            )
482
        );
483
    }
484
485
    /**
486
     * Return's the category with the passed ID.

src/Subjects/BunchSubject.php 1 location

@@ 240-257 (lines=18) @@
237
     * @return integer The requested visibility key
238
     * @throws \Exception Is thrown, if the requested visibility is not available
239
     */
240
    public function getVisibilityIdByValue($visibility)
241
    {
242
243
        // query whether or not, the requested visibility is available
244
        if (isset($this->availableVisibilities[$visibility])) {
245
            return $this->availableVisibilities[$visibility];
246
        }
247
248
        // throw an exception, if not
249
        throw new \Exception(
250
            sprintf(
251
                'Found invalid visibility %s in file %s on line %d',
252
                $visibility,
253
                $this->getFilename(),
254
                $this->getLineNumber()
255
            )
256
        );
257
    }
258
259
    /**
260
     * Add the passed category ID to the product's category list.