Placement : top, bottom, left, right
@param string|null $placement
@param string|null $default
@return boolean
963150
public static function checkPlacement(&$placement, $default = null)
    {
        if (!in_array($placement, ['top', 'bottom', 'left', 'right'])) {
            self::notice('Bad placement [' . $placement . ']');
            $placement = $default;
            return false;
        }
        return true;
    }
496525
public function getPlacementOptions()
    {
        return [
            self::PLACEMENT_AUTO => _t(__CLASS__ . '.AUTO', 'Auto'),
            self::PLACEMENT_TOP => _t(__CLASS__ . '.TOP', 'Top'),
            self::PLACEMENT_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
            self::PLACEMENT_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right'),
            self::PLACEMENT_BOTTOM => _t(__CLASS__ . '.BOTTOM', 'Bottom'),
        ];
    }
1200506
public function getUploadDir( $default = null ) {

		$prop = $this->properties[ self::PROP_UPLOAD_DIR ];

		if( isset( $prop ) && strlen( $prop ) > 0 ) {

			return $prop;
		}

		return $default;
	}
619114
static function ltrim_position($content, $position, $br = true)
    {
        $blanks = array("\t", "\0", "\x0B", " ");

        if ($br) {
            $blanks[] = "\r";
            $blanks[] = "\n";
        }

        while (isset($content[$position]) && isset($content[$position + 1])
            && in_array($content[$position], $blanks, true)
        ) {
            $position++;
        }

        return $position;
    }
855239
public function bool($name, $default = null)
    {
        $cmnd = $name.' tinyint(1)';
        //
        if (!empty($default)) {
            $default = $default ? '1' : '0';
            $cmnd .= " DEFAULT $default ";
        }
        //
        self::$colmuns[] = $cmnd;
        //
        return $this;
    }
644899
protected function setDefault($default)
    {
        if ($this->isNullable() && $default === null) {
            $this->default = 'null';

            return $this;
        }

        if ($default === null) {
            $this->default = '';

            return $this;
        }

        switch ($this->getType()->getType()) {
            case 'string':
                $this->default = "'" . $default . "'";
                break;
            case 'bool':
                $this->default = var_export((bool) $default, true);
                break;
            default:
                $this->default = $default;
        }

        return $this;
    }
985691
function placementText( $placement = false )
    {
        $placementText = false;
        if ( $placement !== false )
        {
            if ( isset( $placement['start'] ) and
                 isset( $placement['stop'] ) and
                 isset( $placement['templatefile'] ) )
            {
                $line = $placement['start']['line'];
                $column = $placement['start']['column'];
                $templateFile = $placement['templatefile'];
            }
            else
            {
                $line = $placement[0][0];
                $column = $placement[0][1];
                $templateFile = $placement[2];
            }

            $placementText = " @ $templateFile:$line" . "[$column]";
        }
        return $placementText;
    }
877932
private function setNullsPosition($nullsPosition)
    {
        if (!\in_array($nullsPosition, [self::NULLS_FIRST, self::NULLS_LAST])) {
            throw new \InvalidArgumentException('Invalid nulls position: ' . $nullsPosition);
        }

        $this->nullsPosition = $nullsPosition;

        return $this;
    }
1013672
public function currentPosition()
    {
        $parent = $this->parent();
        $collection = $parent ? $parent->collection('content', false) : null;
        if ($collection instanceof Collection) {
            return $collection->currentPosition($this->path());
        }

        return 1;
    }
563422
public function firstErrorOrWarning($default=null) {
        $r=$this->firstError();
        if ($r===null) $r=$this->firstWarning();
        return ($r===null)?$default:$r;
    }
34095
private function getOrderDirection(): string
    {
        $result = !empty($this->searchData['sort_by_order']) ?
            $this->searchData['sort_by_order'] :
            Options::DEFAULT_SORT_BY_ORDER;

        return $result;
    }
977116
public function whereFirstOrDefault($where, $default=null)
    {
        $where = LambdaUtils::toConditionCallable($where);
        foreach($this as $record)
        {
            if(call_user_func($where, $record))
            {
                return $record;
            }
        }
        return $default;
    }
980020
protected function validatePlacement($placement)
    {
        if (!in_array($placement, $allowed = $this->allowedPlacements(), true)) {
            throw new Exception(sprintf('Unknown placement "%s". Use one of [%s]', $placement, implode(', ', $allowed)));
        }
    }
985298
public function getPlacement()
    {
        if (($parent = $this->getParent()) && $parent->Placement) {
            return $parent->Placement;
        }
        
        return $this->config()->default_placement;
    }
677264
public function menu($items, $default = null, $title = 'Choose an item')
    {
        if (isset($items[$default]) && strpos($title, '[') === false) {
            $title .= ' [default: ' . $items[$default] . ']';
        }

        $this->line(sprintf('%s: ', $title));

        $i = 1;
        $keys = array();

        foreach ($items as $key => $item) {
            $keys[$i] = $key;
            $this->line(sprintf('  %d. %s', $i, $item));
            $i++;
        }

        $selected = $this->in();

        if ($selected === '') {
            return $default;
        }

        if (isset($keys[$selected])) {
            return $keys[$selected];
        }

        return $selected;
    }
1152569
public function remaining(string $default = null)
    {
        $matches = [];
        preg_match('/(' . self::pattern($this->configuredPath) . ')([^?]*)?/', $this->calledPath, $matches);
        $last = count($matches) - 1;
        if (2 > $last) {
            return $default;
        }

        if (isset($matches[$last]) && !empty($matches[$last])) {
            return $matches[$last];
        }

        return $default;
    }
1207082
public function first($default = []) {
        if (!$this->performed) {
            $this->select();
        }
        if (isset ($this->resultSets [0])) {
            return $this->resultSets[0];
        }

        return $default;
    }