public function create(NetworkRawMessage $rawMessage): IncomingMessage
    {
        $data = $rawMessage->getData();
        $this->validateArray($data, 'desiredPosition');
        $this->validateNumeric($data['desiredPosition'], 'yaw');
        $this->validateNumeric($data['desiredPosition'], 'roll');
        $this->validateNumeric($data['desiredPosition'], 'pitch');

        $this->validateNumeric($data, 'horizontalThrottle');
        $this->validateNumeric($data, 'verticalThrottle');
        $this->validateBool($data, 'motorsStarted');

        $gyroStatus = new GyroStatus($data['desiredPosition']['yaw'], $data['desiredPosition']['roll'], $data['desiredPosition']['pitch']);
        $motorControl = new MotorControlMessage($gyroStatus, $data['horizontalThrottle'], $data['verticalThrottle'], $data['motorsStarted']);

        return new IncomingMotorControlMessage($rawMessage->getSender(), $motorControl);
    }
public function create(NetworkRawMessage $rawMessage): IncomingMessage
    {
        $data = $rawMessage->getData();
        $this->validateArray($data, 'desiredPosition');
        $this->validateNumeric($data['desiredPosition'], 'yaw');
        $this->validateNumeric($data['desiredPosition'], 'roll');
        $this->validateNumeric($data['desiredPosition'], 'pitch');

        $this->validateNumeric($data, 'horizontalThrottle');
        $this->validateNumeric($data, 'verticalThrottle');
        $this->validateBool($data, 'motorsStarted');

        $gyroStatus = new GyroStatus($data['desiredPosition']['yaw'], $data['desiredPosition']['roll'], $data['desiredPosition']['pitch']);
        $motorControl = new MotorControlMessage($gyroStatus, $data['horizontalThrottle'], $data['verticalThrottle'], $data['motorsStarted']);

        return new IncomingMotorControlMessage($rawMessage->getSender(), $motorControl);
    }
@param NetworkRawMessage $rawMessage

@return IncomingMessage|IncomingMotorControlMessage