Code Duplication    Length = 69-69 lines in 2 locations

src/Charcoal/Object/CategorizableMultipleTrait.php 1 location

@@ 14-82 (lines=69) @@
11
 *
12
 * @see \Charcoal\Object\CategoryInterface Accepted interface.
13
 */
14
trait CategorizableMultipleTrait
15
{
16
    /**
17
     * The type of category the object can belong to.
18
     *
19
     * @var string
20
     */
21
    private $categoryType;
22
23
    /**
24
     * One or more categories the object belongs to.
25
     *
26
     * @var (mixed|CategoryInterface)[]|Traversable
27
     */
28
    protected $categories;
29
30
    /**
31
     * Set the type of category the object can belong to.
32
     *
33
     * @param string $type The category type.
34
     * @throws InvalidArgumentException If the type argument is not a string.
35
     * @return CategorizableMultipleInterface Chainable
36
     */
37
    public function setCategoryType($type)
38
    {
39
        if (!is_string($type)) {
40
            throw new InvalidArgumentException(
41
                'Category type must be a string.'
42
            );
43
        }
44
45
        $this->categoryType = $type;
46
47
        return $this;
48
    }
49
50
    /**
51
     * Retrieve the type of category the object can belong to.
52
     *
53
     * @return string
54
     */
55
    public function getCategoryType()
56
    {
57
        return $this->categoryType;
58
    }
59
60
    /**
61
     * Set the categories the object belongs to.
62
     *
63
     * @param array|Traversable $categories The object's categories.
64
     * @return CategorizableMultipleInterface Chainable
65
     */
66
    public function setCategories($categories)
67
    {
68
        $this->categories = $categories;
69
70
        return $this;
71
    }
72
73
    /**
74
     * Retrieve the categories the object belongs to.
75
     *
76
     * @return array|Traversable
77
     */
78
    public function getCategories()
79
    {
80
        return $this->categories;
81
    }
82
}
83

src/Charcoal/Object/CategorizableTrait.php 1 location

@@ 15-83 (lines=69) @@
12
 * @see \Charcoal\Object\CategoryInterface Accepted interface.
13
 * @see \Charcoal\Object\CategorizableMultipleTrait For objects that can to one or more categories.
14
 */
15
trait CategorizableTrait
16
{
17
    /**
18
     * The type of category the object can belong to.
19
     *
20
     * @var string $categoryType
21
     */
22
    private $categoryType;
23
24
    /**
25
     * The category the object belongs to.
26
     *
27
     * @var mixed|CategoryInterface $category
28
     */
29
    protected $category;
30
31
    /**
32
     * Set the type of category the object can belong to.
33
     *
34
     * @param string $type The category type.
35
     * @throws InvalidArgumentException If the type argument is not a string.
36
     * @return CategorizableInterface Chainable
37
     */
38
    public function setCategoryType($type)
39
    {
40
        if (!is_string($type)) {
41
            throw new InvalidArgumentException(
42
                'Category type must be a string.'
43
            );
44
        }
45
46
        $this->categoryType = $type;
47
48
        return $this;
49
    }
50
51
    /**
52
     * Retrieve the type of category the object can belong to.
53
     *
54
     * @return string
55
     */
56
    public function getCategoryType()
57
    {
58
        return $this->categoryType;
59
    }
60
61
    /**
62
     * Set the category the object belongs to.
63
     *
64
     * @param mixed $category The object's category.
65
     * @return CategorizableInterface Chainable
66
     */
67
    public function setCategory($category)
68
    {
69
        $this->category = $category;
70
71
        return $this;
72
    }
73
74
    /**
75
     * Retrieve the category the object belongs to.
76
     *
77
     * @return mixed
78
     */
79
    public function getCategory()
80
    {
81
        return $this->category;
82
    }
83
}
84