1 | <?php |
||
13 | class BlockHashTable { |
||
14 | |||
15 | |||
16 | private $hashTable; |
||
17 | |||
18 | |||
19 | const IS_USED = 'isUsed'; |
||
20 | |||
21 | |||
22 | const BLOCK_VALUE = 'block'; |
||
23 | |||
24 | |||
25 | |||
26 | public function __construct() { |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Build a hash table of declaration blocks from |
||
34 | * a given Document object |
||
35 | * |
||
36 | * @param Document $css |
||
37 | */ |
||
38 | public function build(Document $css) { |
||
46 | |||
47 | |||
48 | |||
49 | /** |
||
50 | * Serialize the contents of the Declaration block and hash the result |
||
51 | * |
||
52 | * @param DeclarationBlock $block |
||
53 | * |
||
54 | * @return string |
||
55 | * An md5 hash representing the DeclarationBlock object |
||
56 | */ |
||
57 | public function hashBlock(DeclarationBlock $block) { |
||
61 | |||
62 | |||
63 | |||
64 | /** |
||
65 | * Set the used flag for the given block at a given hash index |
||
66 | * |
||
67 | * @param string $hash |
||
68 | * A hashed representation of a DeclarationBlock |
||
69 | * |
||
70 | * @param bool $value |
||
71 | * The boolean value to set the flag as |
||
72 | */ |
||
73 | public function setUsedFlag($hash, $value) { |
||
77 | |||
78 | |||
79 | |||
80 | /** |
||
81 | * Get the flag value for the block at a given hash index |
||
82 | * |
||
83 | * @param string $hash |
||
84 | * A hashed representation of a DeclarationBlock |
||
85 | * |
||
86 | * @return bool |
||
87 | * The value of the flag |
||
88 | */ |
||
89 | public function getUsedFlag($hash) { |
||
93 | |||
94 | |||
95 | |||
96 | /** |
||
97 | * Get the block at a given hash index |
||
98 | * |
||
99 | * @param string hash |
||
100 | * A hashed representation of a DeclarationBlock |
||
101 | * |
||
102 | * @return DeclarationBlock |
||
103 | * The declaration block at index $hash |
||
104 | */ |
||
105 | public function getBlock($hash) { |
||
109 | |||
110 | |||
111 | |||
112 | /** |
||
113 | * Set a hashTable value |
||
114 | * |
||
115 | * @param DeclarationBlock $block |
||
116 | * |
||
117 | * @param $value |
||
118 | * A boolean flag to set IS_USED with |
||
119 | */ |
||
120 | public function setBlock(DeclarationBlock $block, $value = false) { |
||
126 | |||
127 | |||
128 | |||
129 | /** |
||
130 | * @return |
||
131 | * Return a copy of the hashTable |
||
132 | */ |
||
133 | public function getBlockCollection() { |
||
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * Determine if a block is in the hash table |
||
142 | * |
||
143 | * @param DeclarationBlock $block |
||
144 | * |
||
145 | * @return bool |
||
146 | * True if block is found |
||
147 | */ |
||
148 | public function hasBlock(DeclarationBlock $block) { |
||
154 | |||
155 | } |
||
156 |