/** * @covers ::binToHex */ public function testConvertingFromBinToHex() { foreach (self::$convertData as $name => $data) { $binary = $data['binary']; $hexadecimal = $data['hexadecimal']; $msg = 'Convert "%s" from binary to hexadecimal form.'; $result = DataConverter::binToHex($binary); $this->assertEquals($hexadecimal, $result, sprintf($msg, $name)); } }
/** * Helper method converting input data from binary string. * * @param string $binary * @param string $type * @param string $pad * * @return string */ private function _convertFromBin($binary, $base, $pad) { switch ($base) { case 2: return DataConverter::pad($binary, $pad ? $this->binSize : 0); case 10: return DataConverter::binToDec($binary, $pad ? $this->decSize : 0); case 16: return DataConverter::binToHex($binary, $pad ? $this->hexSize : 0); } }