Overview

Namespaces

  • Charcoal
    • Object
    • User
      • Acl

Classes

  • Charcoal\Object\Content
  • Charcoal\Object\ObjectRevision
  • Charcoal\Object\ObjectRoute
  • Charcoal\Object\ObjectSchedule
  • Charcoal\Object\UserData
  • Charcoal\User\AbstractUser
  • Charcoal\User\Acl\Manager
  • Charcoal\User\Acl\Permission
  • Charcoal\User\Acl\PermissionCategory
  • Charcoal\User\Acl\Role
  • Charcoal\User\Authenticator
  • Charcoal\User\Authorizer
  • Charcoal\User\AuthToken
  • Charcoal\User\AuthTokenMetadata
  • Charcoal\User\GenericUser

Interfaces

  • Charcoal\Object\ArchivableInterface
  • Charcoal\Object\CategorizableInterface
  • Charcoal\Object\CategorizableMultipleInterface
  • Charcoal\Object\CategoryInterface
  • Charcoal\Object\ContentInterface
  • Charcoal\Object\HierarchicalInterface
  • Charcoal\Object\ObjectRevisionInterface
  • Charcoal\Object\ObjectRouteInterface
  • Charcoal\Object\ObjectScheduleInterface
  • Charcoal\Object\PublishableInterface
  • Charcoal\Object\RevisionableInterface
  • Charcoal\Object\RoutableInterface
  • Charcoal\Object\UserDataInterface
  • Charcoal\User\UserInterface

Traits

  • Charcoal\Object\ArchivableTrait
  • Charcoal\Object\CategorizableMultipleTrait
  • Charcoal\Object\CategorizableTrait
  • Charcoal\Object\CategoryTrait
  • Charcoal\Object\HierarchicalTrait
  • Charcoal\Object\PublishableTrait
  • Charcoal\Object\RevisionableTrait
  • Charcoal\Object\RoutableTrait
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Charcoal\Object;
 4: 
 5: use \InvalidArgumentException;
 6: 
 7: /**
 8:  * Categorizable defines objects that can be associated to a category.
 9:  *
10:  * Basic implementation of {@see \Charcoal\Object\CategorizableInterface}.
11:  *
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 categoryType()
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 category()
80:     {
81:         return $this->category;
82:     }
83: }
84: 
API documentation generated by ApiGen