diff --git a/src/conf/css.php b/src/conf/css.php
new file mode 100644
index 0000000..dfe3b91
--- /dev/null
+++ b/src/conf/css.php
@@ -0,0 +1,10 @@
+ "color:#df5000;font-size:14px"
+];
\ No newline at end of file
diff --git a/src/decorator/DecoratorComponent.php b/src/decorator/DecoratorComponent.php
index 3513035..0dc0370 100644
--- a/src/decorator/DecoratorComponent.php
+++ b/src/decorator/DecoratorComponent.php
@@ -25,6 +25,11 @@ abstract class DecoratorComponent
*/
protected $_tail;
+ /**
+ * @var array
+ */
+ public $classList = [];
+
/**
* @var AbstractDump
*/
@@ -36,12 +41,55 @@ abstract class DecoratorComponent
*/
public function __construct(AbstractDump $dump)
{
+ $this->dump = $dump;
+ $this->initStyle();
+ }
+
+ /**
+ * 初始化css
+ */
+ protected function initStyle()
+ {
+ $config = require_once __DIR__ . '/../conf/css.php';
+ $styleStr = "";
+ }
+ echo $styleStr;
+ }
+
+ /**
+ * 添加样式
+ * @param $className
+ * @return $this
+ */
+ public function addClass($className)
+ {
+ array_push($this->classList, $className);
+ return $this;
+ }
+
+ /**
+ * 添加css并转发给display
+ * @return mixed
+ */
+ public function show()
+ {
+// 设置tag
$parts = explode("\\", static::class);
$class = strtolower(array_pop($parts));
- $this->_head = "<" . $class . ">";
+// 设置class
+ $classStr = implode(' ', $this->classList);
+ $this->_head = "<" . $class . " class='$classStr'>";
$this->_tail = "" . $class . ">";
- $this->dump = $dump;
+ return static::display();
}
+ /**
+ * @return mixed
+ */
abstract public function display();
}
\ No newline at end of file
diff --git a/src/decorator/Span.php b/src/decorator/Span.php
index 9c90b56..f217fce 100644
--- a/src/decorator/Span.php
+++ b/src/decorator/Span.php
@@ -16,6 +16,7 @@ class Span extends DecoratorComponent
public function display()
{
+ echo "";
echo $this->_head . $this->dump->value . $this->_tail;
}
}
\ No newline at end of file
diff --git a/src/render/DumpString.php b/src/render/DumpString.php
index 615ae91..b79e111 100644
--- a/src/render/DumpString.php
+++ b/src/render/DumpString.php
@@ -30,9 +30,11 @@ public function __construct($value)
$this->value = $value;
}
+
public function render()
{
$decorator = new Span($this);
- $decorator->display();
+ $decorator->addClass('nine-span')
+ ->show();
}
}
\ No newline at end of file