private function serializeArea(Area $area)
    {
        $areaData = [
            'id' => $area->getUuid(),
            'color' => $area->getColor(),
        ];

        $position = explode(',', $area->getValue());

        switch ($area->getShape()) {
            case 'circle':
                $areaData['shape'] = 'circle';
                $areaData['radius'] = $area->getSize() / 2;

                // We store the top left corner, so we need to calculate the real center
                $center = $this->serializeCoords($position);
                $center['x'] += $areaData['radius'];
                $center['y'] += $areaData['radius'];
                $areaData['center'] = $center;

                break;
            // For retro-compatibility purpose.
            // It doesn't exist anymore in the schema and is handled as rect
            case 'square':
                $areaData['shape'] = 'rect';
                $areaData['coords'] = [
                    // top-left coords
                    $this->serializeCoords($position),
                    // bottom-right coords
                    $this->serializeCoords([$position[0] + $area->getSize(), $position[1] + $area->getSize()]),
                ];
                break;
            case 'rect':
                $areaData['shape'] = 'rect';
                $areaData['coords'] = [
                    $this->serializeCoords(array_slice($position, 0, 2)),
                    $this->serializeCoords(array_slice($position, 2, 2)),
                ];
                break;
        }

        return $areaData;
    }
private function serializeArea(Area $area)
    {
        $areaData = [
            'id' => $area->getUuid(),
            'color' => $area->getColor(),
        ];

        $position = explode(',', $area->getValue());

        switch ($area->getShape()) {
            case 'circle':
                $areaData['shape'] = 'circle';
                $areaData['radius'] = $area->getSize() / 2;

                // We store the top left corner, so we need to calculate the real center
                $center = $this->serializeCoords($position);
                $center['x'] += $areaData['radius'];
                $center['y'] += $areaData['radius'];
                $areaData['center'] = $center;

                break;
            // For retro-compatibility purpose.
            // It doesn't exist anymore in the schema and is handled as rect
            case 'square':
                $areaData['shape'] = 'rect';
                $areaData['coords'] = [
                    // top-left coords
                    $this->serializeCoords($position),
                    // bottom-right coords
                    $this->serializeCoords([$position[0] + $area->getSize(), $position[1] + $area->getSize()]),
                ];
                break;
            case 'rect':
                $areaData['shape'] = 'rect';
                $areaData['coords'] = [
                    $this->serializeCoords(array_slice($position, 0, 2)),
                    $this->serializeCoords(array_slice($position, 2, 2)),
                ];
                break;
        }

        return $areaData;
    }
private function serializeArea ( Area $ area ) { $ areaData = [ 'id' => $ area -> getUuid ( ) , 'color' => $ area -> getColor ( ) , ] ; $ position = explode ( ',' , $ area -> getValue ( ) ) ; switch ( $ area -> getShape ( ) ) { case 'circle' : $ areaData [ 'shape' ] = 'circle' ; $ areaData [ 'radius' ] = $ area -> getSize ( ) / 2 ; // We store the top left corner, so we need to calculate the real center $ center = $ this -> serializeCoords ( $ position ) ; $ center [ 'x' ] += $ areaData [ 'radius' ] ; $ center [ 'y' ] += $ areaData [ 'radius' ] ; $ areaData [ 'center' ] = $ center ; break ; // For retro-compatibility purpose. // It doesn't exist anymore in the schema and is handled as rect case 'square' : $ areaData [ 'shape' ] = 'rect' ; $ areaData [ 'coords' ] = [ // top-left coords $ this -> serializeCoords ( $ position ) , // bottom-right coords $ this -> serializeCoords ( [ $ position [ 0 ] + $ area -> getSize ( ) , $ position [ 1 ] + $ area -> getSize ( ) ] ) , ] ; break ; case 'rect' : $ areaData [ 'shape' ] = 'rect' ; $ areaData [ 'coords' ] = [ $ this -> serializeCoords ( array_slice ( $ position , 0 , 2 ) ) , $ this -> serializeCoords ( array_slice ( $ position , 2 , 2 ) ) , ] ; break ; } return $ areaData ; }
Serializes an Area.

@param Area $area

@return array
Serializes an Area .