SkinImage: throw on wrong data length

This commit is contained in:
Dylan K. Taylor 2019-12-11 22:45:14 +00:00
parent 1171bae691
commit dbca36e5e2

View File

@ -34,6 +34,9 @@ class SkinImage{
private $data;
public function __construct(int $height, int $width, string $data){
if(($expected = $height * $width * 4) !== ($actual = strlen($data))){
throw new \InvalidArgumentException("Data should be exactly $expected bytes, got $actual bytes");
}
$this->height = $height;
$this->width = $width;
$this->data = $data;