File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 66
77class HashConfig
88{
9+ const CHARSET_UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " ;
10+ const CHARSET_LOWERCASE = "abcdefghijklmnopqrstuvwxyz " ;
11+ const CHARSET_NUMERIC = "0123456789 " ;
12+
913 protected $ length ;
1014
1115 protected $ count = 1 ;
@@ -23,7 +27,7 @@ class HashConfig
2327 public function __construct ($ length = 16 )
2428 {
2529 $ this ->length = $ length ;
26- $ this ->charset = Charset:: LOWERCASE -> value . Charset:: UPPERCASE -> value . Charset:: NUMERIC -> value ;
30+ $ this ->charset = self :: CHARSET_LOWERCASE . self :: CHARSET_UPPERCASE . self :: CHARSET_NUMERIC ;
2731 }
2832
2933 public static function make ($ length = 16 )
@@ -70,21 +74,21 @@ public function charset(string $charset): self
7074
7175 public function upperCaseOnly (): self
7276 {
73- $ this ->charset = Charset:: UPPERCASE -> value ;
77+ $ this ->charset = self :: CHARSET_UPPERCASE ;
7478
7579 return $ this ;
7680 }
7781
7882 public function lowerCaseOnly (): self
7983 {
80- $ this ->charset = Charset:: LOWERCASE -> value ;
84+ $ this ->charset = self :: CHARSET_LOWERCASE ;
8185
8286 return $ this ;
8387 }
8488
8589 public function numbersOnly (): self
8690 {
87- $ this ->charset = Charset:: NUMERIC -> value ;
91+ $ this ->charset = self :: CHARSET_NUMERIC ;
8892
8993 return $ this ;
9094 }
Original file line number Diff line number Diff line change 33namespace Stfn \RandomHash \Tests ;
44
55use PHPUnit \Framework \TestCase ;
6- use Stfn \RandomHash \Charset ;
76use Stfn \RandomHash \InvalidConfigException ;
87use Stfn \RandomHash \RandomHash ;
98use Stfn \RandomHash \HashConfig ;
@@ -124,7 +123,7 @@ public function test_if_it_can_generate_alphanumeric()
124123 {
125124 $ config = new HashConfig ();
126125 $ config ->length (10 )
127- ->charset (Charset:: UPPERCASE -> value . Charset:: LOWERCASE -> value . Charset:: NUMERIC -> value );
126+ ->charset (HashConfig:: CHARSET_UPPERCASE . HashConfig:: CHARSET_LOWERCASE . HashConfig:: CHARSET_NUMERIC );
128127
129128 $ instance = new RandomHash ($ config );
130129 $ hash = $ instance ->generate ();
You can’t perform that action at this time.
0 commit comments