final public function export(): array
    {
        $finalArray = [];
        $mandatoryFields = $this->getMandatoryFields();

        $cleanObject = new $this();
        foreach ($cleanObject as $fieldId => $value) {
            if ($this->$fieldId === $cleanObject->$fieldId) {
                if (\in_array($fieldId, $mandatoryFields, true)) {
                    $missingMandatoryField = new MissingMandatoryField(sprintf(
                        'The field "%s" for class "%s" is mandatory and empty, please correct',
                        $fieldId,
                        \get_class($cleanObject)
                    ));
                    $missingMandatoryField->method = \get_class($cleanObject);
                    $missingMandatoryField->methodInstance = $this;
                    throw $missingMandatoryField;
                }
            } else {
                $finalArray[$fieldId] = $this->$fieldId;
            }
        }

        return $finalArray;
    }
final public function export(): array
    {
        $finalArray = [];
        $mandatoryFields = $this->getMandatoryFields();

        $cleanObject = new $this();
        foreach ($cleanObject as $fieldId => $value) {
            if ($this->$fieldId === $cleanObject->$fieldId) {
                if (\in_array($fieldId, $mandatoryFields, true)) {
                    $missingMandatoryField = new MissingMandatoryField(sprintf(
                        'The field "%s" for class "%s" is mandatory and empty, please correct',
                        $fieldId,
                        \get_class($cleanObject)
                    ));
                    $missingMandatoryField->method = \get_class($cleanObject);
                    $missingMandatoryField->methodInstance = $this;
                    throw $missingMandatoryField;
                }
            } else {
                $finalArray[$fieldId] = $this->$fieldId;
            }
        }

        return $finalArray;
    }
final public function export ( ) : array { $ finalArray = [ ] ; $ mandatoryFields = $ this -> getMandatoryFields ( ) ; $ cleanObject = new $ this ( ) ; foreach ( $ cleanObject as $ fieldId => $ value ) { if ( $ this -> $ fieldId === $ cleanObject -> $ fieldId ) { if ( \ in_array ( $ fieldId , $ mandatoryFields , true ) ) { $ missingMandatoryField = new MissingMandatoryField ( sprintf ( 'The field "%s" for class "%s" is mandatory and empty, please correct' , $ fieldId , \ get_class ( $ cleanObject ) ) ) ; $ missingMandatoryField -> method = \ get_class ( $ cleanObject ) ; $ missingMandatoryField -> methodInstance = $ this ; throw $ missingMandatoryField ; } } else { $ finalArray [ $ fieldId ] = $ this -> $ fieldId ; } } return $ finalArray ; }
Exports the class to an array in order to send it to the Telegram servers without extra fields that we don't need

@return array
@throws MissingMandatoryField
Exports the class to an array in order to send it to the Telegram servers without extra fields that we don t need