44 foreach($pixels as $row){
45 if($rowLength ===
null){
46 $rowLength = count($row);
47 }elseif(count($row) !== $rowLength){
48 throw new \InvalidArgumentException(
"All rows must have the same number of pixels");
51 if($rowLength ===
null){
52 throw new \InvalidArgumentException(
"No pixels provided");
54 if($rowLength > self::MAX_WIDTH){
55 throw new \InvalidArgumentException(
"Image width must be at most " . self::MAX_WIDTH .
" pixels wide");
57 if(count($pixels) > self::MAX_HEIGHT){
58 throw new \InvalidArgumentException(
"Image height must be at most " . self::MAX_HEIGHT .
" pixels tall");
60 $this->height = count($pixels);
61 $this->width = $rowLength;
62 $this->pixels = $pixels;