Skip to content

Commit d456060

Browse files
committed
Red Summer
1 parent e704a67 commit d456060

File tree

5 files changed

+127
-121
lines changed

5 files changed

+127
-121
lines changed

Cli/Key.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
namespace Lib\Cli;
1616

17-
use Lib;
18-
1917
/**
2018
* Lib\Cli\Key Class
2119
*

Cli/Main.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
namespace Lib\Cli;
1616

17-
use Lib;
18-
1917
/**
2018
* Lib\Cli\Main Class
2119
*

Cli/Make.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
namespace Lib\Cli;
1616

17-
use Lib;
18-
1917
/**
2018
* Lib\Cli\Make Class
2119
*

Cli/Optimizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Lib\Cli;
1616

17-
use Lib;
17+
use Config\Lib\Cli;
1818

1919
/**
2020
* Lib\Cli\Optimizer Class
@@ -42,7 +42,7 @@ function __construct(
4242
$arg = null
4343
) {
4444

45-
$this->config = \Config\Lib\Cli\Optimizer::this();
45+
$this->config = Cli\Optimizer::this();
4646
$this->cmd = strtolower($cmd);
4747
$this->arg = $arg;
4848
}

Cli/config.php

Lines changed: 125 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
/**
3-
* Config\CLTool
3+
* Config\Lib\Cli
44
* PHP version 7
55
*
6-
* @category CLT
6+
* @category Tools
77
* @package Config
88
* @author Bill Rocha <prbr@ymail.com>
99
* @copyright 2016 Bill Rocha <http://google.com/+BillRocha>
@@ -12,124 +12,136 @@
1212
* @link http://paulorocha.tk/devbr
1313
*/
1414

15-
namespace Config\CLTool;
15+
namespace Config\Lib\Cli;
1616

1717
/**
18-
* CSS Static Class
18+
* Optimizer Config Class
1919
*
20-
* @category CLT
20+
* @category Tools
2121
* @package Config
2222
* @author Bill Rocha <prbr@ymail.com>
2323
* @license <https://opensource.org/licenses/MIT> MIT
2424
* @link http://paulorocha.tk/devbr
2525
*/
2626
class Optimizer
2727
{
28-
private $css = ['path'=>'',
29-
'source'=>'source/',
30-
'bkp'=>'bkp/',
31-
'file'=>'all.css'];
32-
33-
private $cssPack = ['default'=>[]];
34-
35-
private $js = ['path'=>'',
36-
'source'=>'source/',
37-
'bkp'=>'bkp/',
38-
'file'=>'all.js'];
39-
40-
private $jsPack = ['default'=>[]];
41-
42-
43-
private static $jsonFile = false;
44-
private static $node = false;
45-
46-
/**
47-
* Constructor
48-
* @param string|null $file path of config json file
49-
*/
50-
function __construct(string $file = null)
51-
{
52-
if($file == null) $file = static::$jsonFile;
53-
if($file == false) {
54-
static::$jsonFile = __DIR__.'/'.pathinfo(__FILE__, PATHINFO_FILENAME).'.json';
55-
$file = static::$jsonFile;
56-
57-
if(defined('_WWW')) {
58-
$this->css['path'] = _WWW.'css/';
59-
$this->js['path'] = _WWW.'js/';
60-
}
61-
}
62-
63-
if(!file_exists($file)) $this->save();
64-
$this->load();
65-
}
66-
67-
/**
68-
* Get Instance - static this()
69-
* @param string|null $file path of config json file
70-
*
71-
* @return object Self class object
72-
*/
73-
static function this(string $file = null)
74-
{
75-
if(!static::$node) static::$node = new self($file);
76-
return static::$node;
77-
}
78-
79-
/**
80-
* Set params
81-
* @param string $item item name
82-
* @param mixed $value mixed value inserted in
83-
*
84-
* @return object this
85-
*/
86-
function set(string $item, $value)
87-
{
88-
$this->$item = $value;
89-
return $this;
90-
}
91-
92-
/**
93-
* Get params
94-
* @param string $item Name of parameter
95-
*
96-
* @return mixed Contents of 'item' value
97-
*/
98-
function get(string $item)
99-
{
100-
return isset($this->$item) ? $this->$item : false;
101-
}
102-
103-
/**
104-
* Save to Json config file
105-
* @param string|null $file path to save
106-
* @return bool|number number of bytes saved in file or FALSE.
107-
*/
108-
function save(string $file = null)
109-
{
110-
if($file == null) $file = static::$jsonFile;
111-
112-
$a = null;
113-
foreach ($this as $k => $v) {
114-
$a[$k] = $v;
115-
}
116-
return file_put_contents($file, json_encode($a, JSON_PRETTY_PRINT));
117-
}
118-
119-
/**
120-
* Load configuration json file
121-
* @param string|null $file path and filename
122-
* @return bool success (treu/false)
123-
*/
124-
function load(string $file = null)
125-
{
126-
if($file == null) $file = static::$jsonFile;
127-
if(!file_exists($file)) return false;
128-
129-
$a = json_decode(file_get_contents($file));
130-
foreach ($a as $k => $v) {
131-
$this->$k = $v;
132-
}
133-
return true;
134-
}
135-
}
28+
private $css = ['path'=>'',
29+
'source'=>'source/',
30+
'bkp'=>'bkp/',
31+
'file'=>'all.css'];
32+
33+
private $cssPack = ['default'=>[]];
34+
35+
private $js = ['path'=>'',
36+
'source'=>'source/',
37+
'bkp'=>'bkp/',
38+
'file'=>'all.js'];
39+
40+
private $jsPack = ['default'=>[]];
41+
42+
43+
private static $jsonFile = false;
44+
private static $node = false;
45+
46+
/**
47+
* Constructor
48+
* @param string|null $file path of config json file
49+
*/
50+
function __construct(string $file = null)
51+
{
52+
if ($file == null) {
53+
$file = static::$jsonFile;
54+
}
55+
if ($file == false) {
56+
static::$jsonFile = __DIR__.'/'.pathinfo(__FILE__, PATHINFO_FILENAME).'.json';
57+
$file = static::$jsonFile;
58+
59+
if (defined('_WWW')) {
60+
$this->css['path'] = _WWW.'css/';
61+
$this->js['path'] = _WWW.'js/';
62+
}
63+
}
64+
65+
if (!file_exists($file)) {
66+
$this->save();
67+
}
68+
$this->load();
69+
}
70+
71+
/**
72+
* Get Instance - static this()
73+
* @param string|null $file path of config json file
74+
*
75+
* @return object Self class object
76+
*/
77+
static function this(string $file = null)
78+
{
79+
if (!static::$node) {
80+
static::$node = new self($file);
81+
}
82+
return static::$node;
83+
}
84+
85+
/**
86+
* Set params
87+
* @param string $item item name
88+
* @param mixed $value mixed value inserted in
89+
*
90+
* @return object this
91+
*/
92+
function set(string $item, $value)
93+
{
94+
$this->$item = $value;
95+
return $this;
96+
}
97+
98+
/**
99+
* Get params
100+
* @param string $item Name of parameter
101+
*
102+
* @return mixed Contents of 'item' value
103+
*/
104+
function get(string $item)
105+
{
106+
return isset($this->$item) ? $this->$item : false;
107+
}
108+
109+
/**
110+
* Save to Json config file
111+
* @param string|null $file path to save
112+
* @return bool|number number of bytes saved in file or FALSE.
113+
*/
114+
function save(string $file = null)
115+
{
116+
if ($file == null) {
117+
$file = static::$jsonFile;
118+
}
119+
120+
$a = null;
121+
foreach ($this as $k => $v) {
122+
$a[$k] = $v;
123+
}
124+
return file_put_contents($file, json_encode($a, JSON_PRETTY_PRINT));
125+
}
126+
127+
/**
128+
* Load configuration json file
129+
* @param string|null $file path and filename
130+
* @return bool success (treu/false)
131+
*/
132+
function load(string $file = null)
133+
{
134+
if ($file == null) {
135+
$file = static::$jsonFile;
136+
}
137+
if (!file_exists($file)) {
138+
return false;
139+
}
140+
141+
$a = json_decode(file_get_contents($file));
142+
foreach ($a as $k => $v) {
143+
$this->$k = $v;
144+
}
145+
return true;
146+
}
147+
}

0 commit comments

Comments
 (0)