/** * @param string $content */ private function changeEncoding($content) { $this->tokenStore->setEncoding(Bom::getEncoding($content)); $types = $this->tokenStore->getTokens(); $this->minLength = count($types) > 0 ? strlen(array_keys($types)[0]) * 2 : 1; $this->buffer->setMinBufferSize($this->minLength); }
/** * @param null|string[]|string $bom * * @return static */ public function setBom($bom) { $this->boms = $bom; if (!is_null($bom)) { $testBom = is_array($bom) ? reset($bom) : $bom; Bom::getEncoding($testBom); } return $this; }
public function testGetEncodingWillThrowAnExceptionForUnknownBom() { static::expectException(InvalidArgumentException::class); Bom::getEncoding('random'); }