formId; } /** * @param string $formId * @return $this */ public function setFormId( $formId ) { $this->formId = $formId; return $this; } /** * @return string|null */ public function getPlugin() { return $this->plugin; } /** * @param string|null $plugin * @return $this */ public function setPlugin( $plugin ) { $this->plugin = $plugin; return $this; } /** * Get the matches array. * * @return FormFieldMatchDTO[] */ public function getMatches() { return $this->matches; } /** * Set the matches array. * * @param FormFieldMatchDTO[] $matches * @return $this */ public function setMatches( $matches ) { $this->matches = $matches; return $this; } /** * Create a FormSettingsDTO from an associative array. * * @param array $data * @return static */ public static function fromArray( $data ) { $instance = new self(); $instance->formId = $data['formId']; $instance->plugin = isset( $data['plugin'] ) ? $data['plugin'] : null; if ( isset( $data['matches'] ) && is_array( $data['matches'] ) ) { foreach ( $data['matches'] as $match ) { $instance->matches[] = FormFieldMatchDTO::fromArray( $match ); } } return $instance; } /** * Convert the DTO to an associative array. * * @return array */ public function toArray() { return array( 'formId' => $this->formId, 'plugin' => $this->plugin, 'matches' => array_map( function ( FormFieldMatchDTO $match ) { return $match->toArray(); }, $this->matches ), ); } } }