/** * Returns an array of the high level types of the data other than general text or number. * * Types: S (serialized), O (object), J (JSON), b64 (base64), !!! (broken serialized). * * @since 1.0 * * @param mixed $data * * @return array */ public static function get_data_types($data) { $types = array(); if (Options_Pixie_Data_Format::is_base64($data)) { $types[] = 'b64'; $data = base64_decode($data, true); } if (is_serialized($data)) { $types[] = 'S'; if (Options_Pixie_Data_Format::is_broken_serialized($data)) { $types[] = '!!!'; } else { $data = unserialize($data); } } if (is_object($data)) { $types[] = 'O'; } if (Options_Pixie_Data_Format::is_json($data)) { $types[] = 'J'; } return $types; }
/** * @depends test_is_broken_serialized_exists */ public function test_is_broken_serialized_with_clean_serialized() { $input = 'a:1:{s:3:"two";s:4:"four";}'; $result = Options_Pixie_Data_Format::is_broken_serialized($input); $this->assertFalse($result); }