> */ private $blocked_fields; /** * Property value. * * @var string */ private $blocked_reason; /** * Perform the documented operation. * * @param int $id Form ID. * @param string $title Form title. * @param string $provider Provider identifier. * @param Field[] $fields Supported fields. * @param array> $blocked_fields Blocked field records. * @param string $blocked_reason Form-level block reason. */ public function __construct( $id, $title, $provider, array $fields = array(), array $blocked_fields = array(), $blocked_reason = '' ) { $this->id = absint( $id ); $this->title = (string) $title; $this->provider = (string) $provider; $this->fields = $fields; $this->blocked_fields = array_values( $blocked_fields ); $this->blocked_reason = (string) $blocked_reason; } /** * Return the form ID. * * @return int */ public function id() { return $this->id; } /** * Return the form title. * * @return string */ public function title() { return $this->title; } /** * Return the provider identifier. * * @return string */ public function provider() { return $this->provider; } /** * Return supported fields. * * @return Field[] */ public function fields() { return $this->fields; } /** * Return blocked field diagnostics. * * @return array> */ public function blocked_fields() { return $this->blocked_fields; } /** * Return the form-level block reason. * * @return string */ public function blocked_reason() { return $this->blocked_reason; } /** * A form is compatible only when it has at least one supported field and no * blocked field or form-level policy violation. * * @return bool */ public function is_compatible() { return '' === $this->blocked_reason && ! empty( $this->fields ) && empty( $this->blocked_fields ); } /** * Perform the documented operation. * * @return array */ public function to_array() { return array( 'id' => $this->id, 'title' => $this->title, 'provider' => $this->provider, 'fields' => array_map( static function ( Field $field ) { return $field->to_array(); }, $this->fields ), 'blocked_fields' => $this->blocked_fields, 'blocked_reason' => $this->blocked_reason, 'compatible' => $this->is_compatible(), ); } }