1 Star 0 Fork 0

bin_id/ci-admin

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Style.php 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
bin_id 提交于 2018-12-08 16:18 +08:00 . ci-admin
<?php
/**
* Created by PhpStorm.
* User: v_weibyang
* Date: 2018/11/21
* Time: 17:06
*/
class Style
{
private $color;
private $style;
public function __construct(){
$this -> style = array(
"is_exists" => array(
"common" => "%s:%s is already exists!",
"isANSI" => "error:|%s:|highLight:|%s| is already exists!"
),
"created_successfully" => array(
"common" => "%s:%s created successfully!",
"isANSI" => "success:|%s:|highLight:|%s| created successfully!"
),
"create_failed" => array(
"common" => "%s:%s create failed!",
"isANSI" => "error:|%s:|highLight:|%s| create failed!"
)
);
$this -> color = array(
"error:" => "\033[38;5;202;1;4m",
"success:" => "\033[38;5;22;1;4m",
"highLight:" => "\033[38;5;255;1;4m"
);
}
public function run($type, $param1, $param2 = false){
if (!$style = @$this -> style[$type]){
return $this -> error_style('The style is not found!');
}
$content = ANSI ? $style['isANSI'] : $style['common'];
if ($param2){
$content = sprintf($content, ucfirst($param1), $param2);
}else{
$content = sprintf($content, $param1);
}
if (ANSI){
$content = $this -> build_style($content);
}
return $content;
}
protected function build_style($content){
$text_list = explode('|', $content);
$content = $this -> color[$text_list[0]] . $text_list[1];
$content .= $this -> color[$text_list[2]] . $text_list[3];
$content .= $this -> color[$text_list[0]] . $text_list[4];
return $content;
}
public function success_style($content){
return $this -> color['success:'] . $content;
}
public function error_style($content){
return $this -> color['error:'] . $content;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/binid/ci-admin.git
git@gitee.com:binid/ci-admin.git
binid
ci-admin
ci-admin
master

搜索帮助