Complex classes like Kint_Object often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Kint_Object, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
3 | class Kint_Object |
||
4 | { |
||
5 | const ACCESS_NONE = null; |
||
6 | const ACCESS_PUBLIC = 'public'; |
||
7 | const ACCESS_PROTECTED = 'protected'; |
||
8 | const ACCESS_PRIVATE = 'private'; |
||
9 | |||
10 | const OPERATOR_NONE = null; |
||
11 | const OPERATOR_ARRAY = '=>'; |
||
12 | const OPERATOR_OBJECT = '->'; |
||
13 | const OPERATOR_STATIC = '::'; |
||
14 | |||
15 | public $name; |
||
16 | public $type; |
||
17 | public $static = false; |
||
18 | public $const = false; |
||
19 | public $access = self::ACCESS_NONE; |
||
20 | public $owner_class; |
||
21 | public $access_path; |
||
22 | public $operator = self::OPERATOR_NONE; |
||
23 | public $reference = false; |
||
24 | public $size = null; |
||
25 | public $depth = 0; |
||
26 | public $representations = array(); |
||
27 | public $value = null; |
||
28 | public $hints = array(); |
||
29 | |||
30 | public function __construct() |
||
33 | |||
34 | public function addRepresentation(Kint_Object_Representation $rep, $pos = null) |
||
56 | |||
57 | public function replaceRepresentation(Kint_Object_Representation $rep, $pos = null) |
||
66 | |||
67 | public function removeRepresentation($name) |
||
71 | |||
72 | public function getRepresentation($name) |
||
78 | |||
79 | public function getRepresentations() |
||
83 | |||
84 | public function clearRepresentations() |
||
88 | |||
89 | public function getType() |
||
93 | |||
94 | public function getModifiers() |
||
110 | |||
111 | public function getAccess() |
||
122 | |||
123 | public function getName() |
||
127 | |||
128 | public function getOperator() |
||
140 | |||
141 | public function getSize() |
||
145 | |||
146 | public function getValueShort() |
||
156 | |||
157 | public function getAccessPath() |
||
161 | |||
162 | public static function blank($name = null, $access_path = null) |
||
173 | |||
174 | public function transplant(Kint_Object $new) |
||
193 | |||
194 | public static function isSequential(array $array) |
||
198 | |||
199 | public static function sortByAccess(Kint_Object $a, Kint_Object $b) |
||
210 | |||
211 | public static function sortByName(Kint_Object $a, Kint_Object $b) |
||
221 | } |
||
222 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.