private function deserializeArea(Area $area, array $data)
    {
        if (!empty($data['color'])) {
            $area->setColor($data['color']);
        }

        $area->setShape($data['shape']);

        switch ($data['shape']) {
            case 'circle':
                // legacy: the top left corner is stored, not the center
                $x = $data['center']['x'] - $data['radius'];
                $y = $data['center']['y'] - $data['radius'];
                $area->setValue("{$x},{$y}");
                $area->setSize($data['radius'] * 2);
                break;
            case 'rect':
                $area->setValue(sprintf(
                    '%s,%s,%s,%s',
                    $data['coords'][0]['x'],
                    $data['coords'][0]['y'],
                    $data['coords'][1]['x'],
                    $data['coords'][1]['y']
                ));
                $area->setSize($data['coords'][1]['x'] - $data['coords'][0]['x']);
                break;
        }
    }
private function deserializeArea(Area $area, array $data)
    {
        if (!empty($data['color'])) {
            $area->setColor($data['color']);
        }

        $area->setShape($data['shape']);

        switch ($data['shape']) {
            case 'circle':
                // legacy: the top left corner is stored, not the center
                $x = $data['center']['x'] - $data['radius'];
                $y = $data['center']['y'] - $data['radius'];
                $area->setValue("{$x},{$y}");
                $area->setSize($data['radius'] * 2);
                break;
            case 'rect':
                $area->setValue(sprintf(
                    '%s,%s,%s,%s',
                    $data['coords'][0]['x'],
                    $data['coords'][0]['y'],
                    $data['coords'][1]['x'],
                    $data['coords'][1]['y']
                ));
                $area->setSize($data['coords'][1]['x'] - $data['coords'][0]['x']);
                break;
        }
    }
private function deserializeArea ( Area $ area , array $ data ) { if ( ! empty ( $ data [ 'color' ] ) ) { $ area -> setColor ( $ data [ 'color' ] ) ; } $ area -> setShape ( $ data [ 'shape' ] ) ; switch ( $ data [ 'shape' ] ) { case 'circle' : // legacy: the top left corner is stored, not the center $ x = $ data [ 'center' ] [ 'x' ] - $ data [ 'radius' ] ; $ y = $ data [ 'center' ] [ 'y' ] - $ data [ 'radius' ] ; $ area -> setValue ( "{$x},{$y}" ) ; $ area -> setSize ( $ data [ 'radius' ] * 2 ) ; break ; case 'rect' : $ area -> setValue ( sprintf ( '%s,%s,%s,%s' , $ data [ 'coords' ] [ 0 ] [ 'x' ] , $ data [ 'coords' ] [ 0 ] [ 'y' ] , $ data [ 'coords' ] [ 1 ] [ 'x' ] , $ data [ 'coords' ] [ 1 ] [ 'y' ] ) ) ; $ area -> setSize ( $ data [ 'coords' ] [ 1 ] [ 'x' ] - $ data [ 'coords' ] [ 0 ] [ 'x' ] ) ; break ; } }
Deserializes an Area.

@param Area  $area
@param array $data
Deserializes an Area .