Code Duplication    Length = 18-18 lines in 4 locations

src/Subjects/AbstractProductSubject.php 3 locations

@@ 399-416 (lines=18) @@
396
     * @return integer The tax class ID
397
     * @throws \Exception Is thrown, if the tax class with the requested name is not available
398
     */
399
    public function getTaxClassIdByTaxClassName($taxClassName)
400
    {
401
402
        // query whether or not, the requested tax class is available
403
        if (isset($this->taxClasses[$taxClassName])) {
404
            return (integer) $this->taxClasses[$taxClassName][MemberNames::CLASS_ID];
405
        }
406
407
        // throw an exception, if not
408
        throw new \Exception(
409
            sprintf(
410
                'Found invalid tax class name %s in file %s on line %d',
411
                $taxClassName,
412
                $this->getFilename(),
413
                $this->getLineNumber()
414
            )
415
        );
416
    }
417
418
    /**
419
     * Return's the store website for the passed code.
@@ 426-443 (lines=18) @@
423
     * @return integer The store website ID
424
     * @throws \Exception Is thrown, if the store website with the requested code is not available
425
     */
426
    public function getStoreWebsiteIdByCode($code)
427
    {
428
429
        // query whether or not, the requested store website is available
430
        if (isset($this->storeWebsites[$code])) {
431
            return (integer) $this->storeWebsites[$code][MemberNames::WEBSITE_ID];
432
        }
433
434
        // throw an exception, if not
435
        throw new \Exception(
436
            sprintf(
437
                'Found invalid website code %s in file %s on line %d',
438
                $code,
439
                $this->getFilename(),
440
                $this->getLineNumber()
441
            )
442
        );
443
    }
444
445
    /**
446
     * Return's the category with the passed path.
@@ 453-470 (lines=18) @@
450
     * @return array The category
451
     * @throws \Exception Is thrown, if the requested category is not available
452
     */
453
    public function getCategoryByPath($path)
454
    {
455
456
        // query whether or not the category with the passed path exists
457
        if (isset($this->categories[$path])) {
458
            return $this->categories[$path];
459
        }
460
461
        // throw an exception, if not
462
        throw new \Exception(
463
            sprintf(
464
                'Can\'t find category with path %s in file %s on line %d',
465
                $path,
466
                $this->getFilename(),
467
                $this->getLineNumber()
468
            )
469
        );
470
    }
471
472
    /**
473
     * Return's the category with the passed ID.

src/Subjects/BunchSubject.php 1 location

@@ 136-153 (lines=18) @@
133
     * @return integer The requested visibility key
134
     * @throws \Exception Is thrown, if the requested visibility is not available
135
     */
136
    public function getVisibilityIdByValue($visibility)
137
    {
138
139
        // query whether or not, the requested visibility is available
140
        if (isset($this->availableVisibilities[$visibility])) {
141
            return $this->availableVisibilities[$visibility];
142
        }
143
144
        // throw an exception, if not
145
        throw new \Exception(
146
            sprintf(
147
                'Found invalid visibility %s in file %s on line %d',
148
                $visibility,
149
                $this->getFilename(),
150
                $this->getLineNumber()
151
            )
152
        );
153
    }
154
155
    /**
156
     * Add the passed category ID to the product's category list.