Code Duplication    Length = 17-18 lines in 4 locations

src/Entity/Item.php 4 locations

@@ 495-511 (lines=17) @@
492
     *
493
     * @return Item
494
     */
495
    public function setType(Type $type = null)
496
    {
497
        if ($this->type !== $type) {
498
            // romove link on this item for old type
499
            if ($this->type instanceof Type) {
500
                $tmp = $this->type;
501
                $this->type = null;
502
                $tmp->removeItem($this);
503
            }
504
            $this->type = $type;
505
            // add link on this item
506
            if ($this->type instanceof Type) {
507
                $this->type->addItem($this);
508
            }
509
        }
510
511
        return $this;
512
    }
513
514
    /**
@@ 603-619 (lines=17) @@
600
     *
601
     * @return Item
602
     */
603
    public function setCountry(Country $country = null)
604
    {
605
        if ($this->country !== $country) {
606
            // romove link on this item for old country
607
            if ($this->country instanceof Country) {
608
                $tmp = $this->country;
609
                $this->country = null;
610
                $tmp->removeItem($this);
611
            }
612
            $this->country = $country;
613
            // add link on this item
614
            if ($this->country instanceof Country) {
615
                $this->country->addItem($this);
616
            }
617
        }
618
619
        return $this;
620
    }
621
622
    /**
@@ 635-652 (lines=18) @@
632
     *
633
     * @return Item
634
     */
635
    public function setStorage(Storage $storage = null)
636
    {
637
        if ($this->storage !== $storage) {
638
            // romove link on this item for old storage
639
            if ($this->storage instanceof Storage) {
640
                $tmp = $this->storage;
641
                $this->storage = null;
642
                $tmp->removeItem($this);
643
            }
644
            $this->storage = $storage;
645
            // add link on this item
646
            if ($this->storage instanceof Storage) {
647
                $this->storage->addItem($this);
648
            }
649
        }
650
        $this->doClearPath();
651
652
        return $this;
653
    }
654
655
    /**
@@ 867-883 (lines=17) @@
864
     *
865
     * @return Item
866
     */
867
    public function setStudio(Studio $studio = null)
868
    {
869
        if ($this->studio !== $studio) {
870
            // romove link on this item for old studio
871
            if ($this->studio instanceof Studio) {
872
                $tmp = $this->studio;
873
                $this->studio = null;
874
                $tmp->removeItem($this);
875
            }
876
            $this->studio = $studio;
877
            // add link on this item
878
            if ($this->studio instanceof Studio) {
879
                $this->studio->addItem($this);
880
            }
881
        }
882
883
        return $this;
884
    }
885
886
    /**