Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Decorators/FieldDecorator.php')
-rw-r--r--src/Decorators/FieldDecorator.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Decorators/FieldDecorator.php b/src/Decorators/FieldDecorator.php
new file mode 100644
index 00000000..fb4da991
--- /dev/null
+++ b/src/Decorators/FieldDecorator.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * PHPPgAdmin6
+ */
+
+namespace PHPPgAdmin\Decorators;
+
+class FieldDecorator extends Decorator
+{
+ /**
+ * @var mixed|mixed[]
+ */
+ public $fieldName;
+
+ public $defaultValue;
+
+ public function __construct($fieldName, $defaultValue = null)
+ {
+ $this->fieldName = $fieldName;
+
+ $this->defaultValue = $defaultValue;
+ }
+
+ public function value($fields)
+ {
+ if (isset($fields[$this->fieldName])) {
+ return Decorator::get_sanitized_value($fields[$this->fieldName], $fields);
+ }
+
+ return $this->defaultValue;
+ }
+}