Code Duplication    Length = 9-9 lines in 2 locations

src/ArrayHelpers/ByteArrayDispenser.php 2 locations

@@ 121-129 (lines=9) @@
118
	 * @return \chillerlan\Traits\ArrayHelpers\ByteArray|mixed
119
	 * @throws \chillerlan\Traits\TraitException
120
	 */
121
	public function fromHex(string $hex):ByteArray{
122
		$hex = preg_replace('/[\s\r\n\t ]/', '', $hex);
123
124
		if(!$this->isAllowedHex($hex)){
125
			throw new TraitException('invalid hex string');
126
		}
127
128
		return $this->fromString(pack('H*', $hex));
129
	}
130
131
	/**
132
	 * checks if the given (trimmed) JSON string is a an array that contains numbers: [1, 2, 3]
@@ 175-183 (lines=9) @@
172
	 * @return \chillerlan\Traits\ArrayHelpers\ByteArray|mixed
173
	 * @throws \chillerlan\Traits\TraitException
174
	 */
175
	public function fromBase64(string $base64):ByteArray{
176
		$base64 = trim($base64);
177
178
		if(!$this->isAllowedBase64($base64)){
179
			throw new TraitException('invalid base64 string');
180
		}
181
182
		return $this->fromString(base64_decode($base64));
183
	}
184
185
	/**
186
	 * checks if the given (trimmed) string is a binary string: [01] in multiples of 8