/** * Decorate command data * * @param mixed $data * @param mixed $filters * @param string $decorator * @return mixed (string or data) */ private static function __decorate($data, &$decorator, &$filters, $type) { if ($decorator !== null) { switch ($type) { case self::DECORATE_TYPE_ARRAY: return Decorate::data($data, $decorator, $filters); break; case self::DECORATE_TYPE_DETECT: // detect decorate type if (is_array($data)) { return Decorate::data($data, $decorator, $filters); } else { if (strpos($decorator, Decorate::PLACEHOLDER_TEST_VALUE_SEP) !== false) { return Decorate::test($data, $decorator, $filters); } else { return Decorate::string($data, $decorator, $filters); } } break; case self::DECORATE_TYPE_STRING: return Decorate::string($data, $decorator, $filters); break; case self::DECORATE_TYPE_TEST: return Decorate::test($data, $decorator, $filters); break; } } return $data; }
/** * Model printer * * @return string */ public function __toString() { return $this->__decorator !== null && $this->__is_loaded ? Decorate::data($this->__data, $this->__decorator, $this->__decorator_filters) : implode(', ', array_filter($this->__data, function ($v) { return $v !== null; })); }