public function test_String2Binary() { $s = '0000000100000011'; $result = It::string2binary($s); $expected = chr(1) . chr(3); $this->assertEquals($expected, $result); }
public function tmpReportFile() { $this->_logger->log(__METHOD__); $file_name = $this->schedule_process_info->schedule_processed_id; $file_dir = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "schedule_reports"; if (!is_dir($file_dir)) { @mkdir($file_dir, 0777, true); } $file_path = $file_dir . DIRECTORY_SEPARATOR . $file_name; $string = $this->getReportComplete(); if ($this->schedule_info->report_type === 'bufr') { $string = It::string2binary($string); } if (($h = @fopen($file_path, "w+")) !== false) { fwrite($h, $string); fclose($h); } return $this->returnResult(__METHOD__, $file_path); }