Set the required fields - conditionally depending on other fields

@return void

@SuppressWarnings(PHPMD.ExcessiveMethodLength)
515658
protected function setRequiredFieldValuesConditional()
    {
        $requiredFieldValuesConditional = [
            'payment_type' => [
                PaymentMethods::EPS        => [
                    [
                        'billing_country' => 'AT',
                        'currency'        => 'EUR'
                    ]
                ],
                PaymentMethods::SAFETY_PAY => [
                    [
                        'billing_country' => [
                            'AT', 'BE', 'BR', 'CL', 'CO', 'CR', 'DE', 'EC', 'ES', 'MX', 'NL', 'PE', 'PR'
                        ],
                        'currency'        => ['EUR', 'USD']
                    ]
                ],
                PaymentMethods::TRUST_PAY  => [
                    [
                        'billing_country' => 'CZ',
                        'currency'        => 'CZK'
                    ],
                    [
                        'billing_country' => ['CZ', 'SK'],
                        'currency'        => 'EUR'
                    ]
                ],
                PaymentMethods::PRZELEWY24 => [
                    [
                        'billing_country' => 'PL',
                        'currency'        => 'PLN'
                    ]
                ],
                PaymentMethods::IDEAL      => [
                    [
                        'billing_country' => 'NL',
                        'currency'        => 'EUR'
                    ]
                ],
                PaymentMethods::QIWI       => [
                    [
                        'billing_country' => 'RU',
                        'currency'        => ['EUR', 'RUB']
                    ]
                ],
                PaymentMethods::GIRO_PAY   => [
                    [
                        'billing_country' => 'DE',
                        'currency'        => 'EUR'
                    ]
                ],
                PaymentMethods::BCMC       => [
                    [
                        'billing_country' => 'BE',
                        'currency'        => 'EUR'
                    ]
                ],
                PaymentMethods::MYBANK     => [
                    [
                        'billing_country' => ['BE', 'FR', 'IT', 'LU'],
                        'currency'        => 'EUR'
                    ]
                ]
            ]
        ];

        $this->requiredFieldValuesConditional = CommonUtils::createArrayObject($requiredFieldValuesConditional);
    }
229855
public void setupFields()
    {
        FieldInfo field = null;
        field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field.setHidden(true);
        field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Date.class);
        field.setHidden(true);
        field = new FieldInfo(this, DELETED, 10, null, new Boolean(false));
        field.setDataClass(Boolean.class);
        field.setHidden(true);
        field = new FieldInfo(this, CODE, 30, null, null);
        field = new FieldInfo(this, MESSAGE_PROCESS_INFO_ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, MESSAGE_TRANSPORT_ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, MESSAGE_VERSION_ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, ACTIVE, 10, null, new Boolean(true));
        field.setDataClass(Boolean.class);
        field = new FieldInfo(this, DEFAULT_TRANSPORT, 10, null, null);
        field.setDataClass(Boolean.class);
        field = new FieldInfo(this, PROPERTIES, Constants.DEFAULT_FIELD_LENGTH, null, null);
    }
430740
protected function setField($values)
    {
        foreach ($values as $name => $field) {
            $this->fields[$name] = $field;
        }
    }
632798
public function setFields( $fields )
	{
		if( is_array( $fields ) && count( $fields ) )
			$this->fields = $fields;
		else
			trigger_error( 'Field Array of Table Definition must no be empty.', E_USER_ERROR );
	}
903758
public void setupFields()
    {
        FieldInfo field = null;
        field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
    }
358772
public void setupFields()
    {
        FieldInfo field = null;
        for (int iFieldSeq = DBConstants.MAIN_FIELD; iFieldSeq < 256; iFieldSeq++)
        {
            field = this.setupField(iFieldSeq);     // Allocate this Field (may be overidden)
            if (field == null)
                break;                              // End of fields
        }
    }
212964
public function edit_field_set_required($mform) {
        global $USER;
        if ($this->is_required() && ($this->userid == $USER->id || isguestuser())) {
            $mform->addRule($this->inputname, get_string('required'), 'required', null, 'client');
        }
    }
601643
protected function setQuantityField()
    {
        $iQuantity = array_get($this->arImportData, 'quantity');
        if ($iQuantity === null) {
            return;
        }

        $iQuantity = (int) $iQuantity;
        if ($iQuantity < 0) {
            $iQuantity = 0;
        }

        $this->arImportData['quantity'] = $iQuantity;
    }
159562
public function setRequired($required) {
		if(!empty($required))
			$this->validation[] = new Validation\Required;
		$this->_attributes["required"] = "";	
	}
157331
public function setFields($fields)
    {
        foreach ($fields as $name => $value) {
            $this->parameters->addPost($name, $value);
        }
    }
440456
protected function setFields($fields)
    {
        if(is_array($fields)) {
            foreach ( $fields as $field ) {
                if ( !in_array($field, $this->fieldsWhitelist) ) {
                    throw new \InvalidArgumentException(sprintf('The field `%s` was not recognized.', $field));
                }
            }
        } elseif($fields === true) {
            $fields = $this->fieldsWhitelist;
        } else {
            throw new \InvalidArgumentException("The argument passed to setFields was invalid");
        }

        $this->setQueryParam('fields', $fields);
    }
997447
protected function verifyConditionalFields()
    {
        if (isset($this->requiredFieldsOR)) {
            $fields = $this->requiredFieldsOR->getArrayCopy();

            $status = false;

            foreach ($fields as $fieldName) {
                if (isset($this->$fieldName) && !empty($this->$fieldName)) {
                    $status = true;
                }
            }

            if (!$status) {
                throw new \Genesis\Exceptions\ErrorParameter(implode($fields));
            }
        }
    }
1307028
protected function validateOptionsFields()
    {
        if ($this->submittedValues['optionsAllOn1Line'] == PHP_INT_MAX && $this->submittedValues['optionsAllOnOwnLine'] == 1) {
            $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_0');
        }
        if ($this->submittedValues['optionsAllOn1Line'] > $this->submittedValues['optionsAllOnOwnLine'] && $this->submittedValues['optionsAllOnOwnLine'] > 1) {
            $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_1');
        }

        if (isset($this->submittedValues['optionsMaxLength']) && !ctype_digit($this->submittedValues['optionsMaxLength'])) {
            $this->errorMessages['optionsMaxLength'] = $this->t('message_validate_options_2');
        }
    }
1293218
public function addRequiredFields($fields, ...$otherFields)
    {
        if(!is_array($fields)) {
            $fields = [$fields];
        }
        if(!empty($otherFields)) {
            $fields = array_merge($fields, $otherFields);
        }
        if (ArrayLib::is_associative($fields)) {
            foreach ($fields as $k => $v) {
                $constraint = Constraint_required::create();
                if ($v) {
                    $constraint->setMessage($v);
                }
                $this->setConstraint($k, $constraint);
            }
        } else {
            foreach ($fields as $field) {
                $this->setConstraint($field, Constraint_required::create());
            }
        }

        return $this;
    }
642194
public function setFields($values)
    {
        foreach ($values as $field => $value) {
            $this->setField($field, $value);
        }
    }
263051
protected function setFields()
    {
        $this->set = new \stdClass();
        $schema    = $this->schema();

        foreach ($schema as $field => $type)
        {
            if (Helpers\Validate::isNumeric($type) && $field != 'id')
            {
                $this->setField($field, 0);
            }
            else
            {
                $this->setField($field, null);
            }
        }
    }
1317147
protected function setFields($values)
    {
        foreach ($values[0]->fields as $name => $field) {
            $this->fields[$name] = $field;
        }
    }