1 | <?php |
||
23 | class COB { |
||
24 | |||
25 | /// @cond INTERNAL_DOCS |
||
26 | |||
27 | private $format; |
||
28 | private $blocks; |
||
29 | |||
30 | /// @endcond |
||
31 | |||
32 | /// @brief Creates a new COB file |
||
33 | /** |
||
34 | * If you want to create a COB file from scratch, simply don't |
||
35 | * pass anything to the constructor. \n\n |
||
36 | * Alternatively, if you know which kind of COB file you are |
||
37 | * reading, or only want to deal with a specific kind of COB |
||
38 | * file, you can call the LoadC1COB and LoadC2COB functions |
||
39 | * after creating a blank cob file. E.g. ($reader is a IReader) \n\n |
||
40 | * $cob = new COB; \n |
||
41 | * $cob->LoadC1COB($reader); \n |
||
42 | * This code will only parse C1 cobs. |
||
43 | * @param $reader The reader which contains the cob to read from. Can be null. |
||
44 | */ |
||
45 | public function COB(IReader $reader = null) { |
||
50 | |||
51 | /// @cond INTERNAL_DOCS |
||
52 | |||
53 | /// @brief Loads the COB from the IReader. |
||
54 | /** |
||
55 | * Used internally, this function is not for the general public! \n |
||
56 | * This function first identifies which type of COB is in the IReader |
||
57 | * Then decompresses if necessary, then calls LoadC1COB or LoadC2COB. |
||
58 | * @param $reader The reader to read from |
||
59 | */ |
||
60 | private function LoadCOB(IReader $reader) { |
||
75 | |||
76 | /// @endcond |
||
77 | |||
78 | /// @brief Loads a C2 COB from the IReader given |
||
79 | /** |
||
80 | * C2 COBs have multiple blocks, which are accessible via the |
||
81 | * COB::GetBlocks function. |
||
82 | * @param $reader The IReader to load from |
||
83 | */ |
||
84 | public function LoadC2COB(IReader $reader) { |
||
94 | |||
95 | /// @brief Loads a C1 COB from the specified reader |
||
96 | /** |
||
97 | * C1 COBs have just one block, which is a COBAgentBlock. |
||
98 | * This is accessible by calling COB::GetBlocks |
||
99 | * @param $reader the reader to load from |
||
100 | */ |
||
101 | public function LoadC1COB(IReader $reader) { |
||
110 | /// @brief Adds a COBBlock to this COB |
||
111 | /** |
||
112 | * @param $block the block to add. |
||
113 | */ |
||
114 | public function AddBlock(COBBlock $block) { |
||
118 | |||
119 | /// @cond INTERNAL_DOCS |
||
120 | |||
121 | /// @brief Underlying block reader used by C2 COBs |
||
122 | /** |
||
123 | * Reads a block from the specified reader, then instanitates |
||
124 | * a representative COBBlock, and returns it. |
||
125 | */ |
||
126 | private function ReadBlock(IReader $reader) { |
||
149 | |||
150 | /// @endcond |
||
151 | |||
152 | /// @brief Accessor method to get blocks of the given type |
||
153 | /** |
||
154 | * If $type is false, will return all blocks in this agent. \n |
||
155 | * In a C1 COB, there is only one block and it is of the agnt |
||
156 | * type. |
||
157 | * @param $type The type of block to get (agnt, auth, file). False by default. |
||
158 | * @return An array of COBBlocks. |
||
159 | */ |
||
160 | public function GetBlocks($type = false) { |
||
169 | |||
170 | /// @brief Compiles the COB in the given format |
||
171 | /** |
||
172 | * @param $format The format of the COB. If null, assumed it's a creatures 2 COB |
||
173 | * @return A binary string containing the COB. |
||
174 | */ |
||
175 | public function Compile($format = null) { |
||
191 | |||
192 | /// @brief Compiles to a C1 COB. <b>Unimplemented</b> |
||
193 | // TODO: implement this. |
||
194 | public function CompileC1() { |
||
197 | /// @brief Compiles a C2 COB. <b>May not actually work.</b> |
||
198 | // TODO: Check accuracy |
||
199 | public function CompileC2() { |
||
205 | } |
||
206 | ?> |
||
207 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.