public function setData(array $data = null)
    {
        $line_length = $column_length = 0;
        foreach ($data as $x=>$items) {
            if (!is_array($items)) {
                throw new InvalidArgumentException(
                    "Data parameter of matrix must be a 2 dimensional array (array of arrays)!"
                );
            }
            if (count($items)>$line_length) {
                $line_length = count($items) - 1;
            }
            foreach ($items as $subitems) {
                if (count($subitems)>$column_length) {
                    $column_length = count($subitems) - 1;
                }
            }
        }
        $this->_size = array(
            'x' => $line_length,
            'y' => $column_length,
            'c' => ($line_length * $column_length)
        );
        foreach ($data as $x=>$items) {
            $this->data[$x] = $this->_padLine($items);
        }
        $this->_cache = $this->data;
    }
public function setData(array $data = null)
    {
        $line_length = $column_length = 0;
        foreach ($data as $x=>$items) {
            if (!is_array($items)) {
                throw new InvalidArgumentException(
                    "Data parameter of matrix must be a 2 dimensional array (array of arrays)!"
                );
            }
            if (count($items)>$line_length) {
                $line_length = count($items) - 1;
            }
            foreach ($items as $subitems) {
                if (count($subitems)>$column_length) {
                    $column_length = count($subitems) - 1;
                }
            }
        }
        $this->_size = array(
            'x' => $line_length,
            'y' => $column_length,
            'c' => ($line_length * $column_length)
        );
        foreach ($data as $x=>$items) {
            $this->data[$x] = $this->_padLine($items);
        }
        $this->_cache = $this->data;
    }
public function setData ( array $ data = null ) { $ line_length = $ column_length = 0 ; foreach ( $ data as $ x => $ items ) { if ( ! is_array ( $ items ) ) { throw new InvalidArgumentException ( "Data parameter of matrix must be a 2 dimensional array (array of arrays)!" ) ; } if ( count ( $ items ) > $ line_length ) { $ line_length = count ( $ items ) - 1 ; } foreach ( $ items as $ subitems ) { if ( count ( $ subitems ) > $ column_length ) { $ column_length = count ( $ subitems ) - 1 ; } } } $ this -> _size = array ( 'x' => $ line_length , 'y' => $ column_length , 'c' => ( $ line_length * $ column_length ) ) ; foreach ( $ data as $ x => $ items ) { $ this -> data [ $ x ] = $ this -> _padLine ( $ items ) ; } $ this -> _cache = $ this -> data ; }
Set the matrix contents

@param   array   $data
@return  void
@throws  InvalidArgumentException if `$data` is not a 2D array
Set the matrix contents