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

IfEmptyDecorator.php « decorators « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad7cdfc73f9ac5f7f0c9971e78ea586205b31918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

/**
 * PHPPgAdmin v6.0.0-RC4
 */

namespace PHPPgAdmin\Decorators;

class IfEmptyDecorator extends Decorator
{
    public function __construct($value, $empty, $full = null)
    {
        $this->v = $value;
        $this->e = $empty;
        if (null !== $full) {
            $this->f = $full;
        }
    }

    public function value($fields)
    {
        $val = Decorator::get_sanitized_value($this->v, $fields);
        if (empty($val)) {
            return Decorator::get_sanitized_value($this->e, $fields);
        }

        return isset($this->f) ? Decorator::get_sanitized_value($this->f, $fields) : $val;
    }
}