Code Duplication    Length = 17-18 lines in 4 locations

src/Entity/Item.php 4 locations

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