Skip to content

Commit 3130290

Browse files
committed
CamelCase
1 parent f55dd06 commit 3130290

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<?php
2-
namespace jblond;
2+
namespace jblond\cli;
33

44

55
/**
66
* Class cli
7-
* @package jblond
7+
* @package jblond\helper
88
*/
9-
class cli {
9+
class Cli {
1010

1111
/**
1212
* @param string $prompt
13-
* @param array|string $valid_inputs
13+
* @param array|string $validInputs
1414
* @param string $default
1515
* @return string
1616
*/
17-
public function input($prompt, $valid_inputs, $default = ''){
17+
public function input($prompt, $validInputs, $default = ''){
1818
echo $prompt;
1919
$input = trim(fgets(fopen('php://stdin', 'r')));
2020
while(
2121
!isset($input) ||
2222
(
23-
is_array($valid_inputs) &&
24-
!in_array($input, $valid_inputs)
23+
is_array($validInputs) &&
24+
!in_array($input, $validInputs)
2525
) ||
2626
(
27-
$valid_inputs == 'is_file' &&
27+
$validInputs == 'is_file' &&
2828
!is_file($input)
2929
)
3030
){
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<?php
2-
namespace jblond;
2+
namespace jblond\cli;
33

44
/**
5-
* Class cli_colors
5+
* Class CliColors
66
*
7-
* works on bash
8-
*
9-
* @package jblond
7+
* Works on bash
8+
* @package jblond\helper
109
*/
11-
class cli_colors {
10+
class CliColors {
1211

1312
/**
1413
* @var array
1514
*/
16-
private $foreground_colors = array(
15+
private $foregroundColors = array(
1716
'black' => '0;30',
1817
'dark_gray' => '1;30',
1918
'blue' => '0,34',
@@ -35,7 +34,7 @@ class cli_colors {
3534
/**
3635
* @var array
3736
*/
38-
private $background_colors = array(
37+
private $backgroundColors = array(
3938
'black' => '40',
4039
'red' => '41',
4140
'green' => '42',
@@ -46,25 +45,24 @@ class cli_colors {
4645
'light_gray' => '47'
4746
);
4847

49-
5048
/**
5149
* @param string $string
5250
* @param null|string $foreground_color
5351
* @param null|string $background_color
5452
* @return string
5553
*/
56-
public function get_colored_string($string, $foreground_color = null, $background_color = null){
54+
public function getColoredString($string, $foreground_color = null, $background_color = null){
5755
$colored_string = '';
5856

59-
if(isset($this->foreground_colors["$foreground_color"])){
60-
$colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
57+
if(isset($this->foregroundColors["$foreground_color"])){
58+
$colored_string .= "\033[" . $this->foregroundColors[$foreground_color] . "m";
6159
}
6260

63-
if(isset($this->background_colors["$background_color"])){
64-
$colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
61+
if(isset($this->backgroundColors["$background_color"])){
62+
$colored_string .= "\033[" . $this->backgroundColors[$background_color] . "m";
6563
}
6664

67-
$colored_string .= $string . "\033[0m";
65+
$colored_string .= $string . "\033[0m";
6866
return $colored_string;
6967
}
7068

@@ -73,17 +71,16 @@ public function get_colored_string($string, $foreground_color = null, $backgroun
7371
*
7472
* @return array
7573
*/
76-
public function get_foreground_colors() {
77-
return array_keys($this->foreground_colors);
74+
public function getForegroundColors() {
75+
return array_keys($this->foregroundColors);
7876
}
7977

80-
8178
/**
8279
* Returns all background color names
8380
*
8481
* @return array
8582
*/
86-
public function get_background_colors() {
87-
return array_keys($this->background_colors);
83+
public function getBackgroundColors() {
84+
return array_keys($this->backgroundColors);
8885
}
8986
}

src/cli.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
2-
require 'classes/jblond/cli.class.php';
3-
require 'classes/jblond/cli_colors.class.php';
4-
$cli = new \jblond\cli();
5-
$colors = new \jblond\cli_colors();
6-
$string = $colors->get_colored_string('This is a test','red','black');
2+
require 'classes/jblond/cli/Cli.php';
3+
require 'classes/jblond/cli/CliColors.php';
4+
$cli = new \jblond\cli\Cli();
5+
$colors = new \jblond\cli\CliColors();
6+
$string = $colors->getColoredString('This is a test','red','black');
77
$cli->output($string);
88
$cli->error($string);
99
echo $cli->input('Hello world: ',array('Hello','world'));
1010
echo $cli->input('Test2: ', 'test');
11+
print_r($colors->getForegroundColors());
12+
print_r($colors->getBackgroundColors());

0 commit comments

Comments
 (0)