Completed
Push — master ( 5480b8...7a9b43 )
by Vitaliy
02:04
created
source/Method/MethodOpenSSL.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
     /**
8 8
      * @inheritdoc
9 9
      */
10
-    public static function isAvailable ()
10
+    public static function isAvailable()
11 11
     {
12
-        return function_exists( 'openssl_random_pseudo_bytes' );
12
+        return function_exists('openssl_random_pseudo_bytes');
13 13
     }
14 14
 
15 15
     /**
16 16
      * @inheritdoc
17 17
      */
18
-    public function getRandomInt ( $limit )
18
+    public function getRandomInt($limit)
19 19
     {
20
-        return hexdec( bin2hex( openssl_random_pseudo_bytes( 3 ) ) ) % ( $limit + 1 );
20
+        return hexdec(bin2hex(openssl_random_pseudo_bytes(3))) % ($limit + 1);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
source/Method/MethodMT.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
     /**
8 8
      * @inheritdoc
9 9
      */
10
-    public static function isAvailable ()
10
+    public static function isAvailable()
11 11
     {
12
-        return function_exists( 'mt_rand' );
12
+        return function_exists('mt_rand');
13 13
     }
14 14
 
15 15
     /**
16 16
      * @inheritdoc
17 17
      */
18
-    public function getRandomInt ( $limit )
18
+    public function getRandomInt($limit)
19 19
     {
20
-        return mt_rand( 0, $limit );
20
+        return mt_rand(0, $limit);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
source/Method/MethodInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
     /**
8 8
      * @return bool
9 9
      */
10
-    public static function isAvailable ();
10
+    public static function isAvailable();
11 11
 
12 12
     /**
13 13
      * @param int $limit
14 14
      *
15 15
      * @return int
16 16
      */
17
-    public function getRandomInt ( $limit );
17
+    public function getRandomInt($limit);
18 18
 }
Please login to merge, or discard this patch.
source/Method/MethodRandomInt.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
     /**
8 8
      * @inheritdoc
9 9
      */
10
-    public static function isAvailable ()
10
+    public static function isAvailable()
11 11
     {
12
-        return function_exists( 'random_int' );
12
+        return function_exists('random_int');
13 13
     }
14 14
 
15 15
     /**
16 16
      * @inheritdoc
17 17
      */
18
-    public function getRandomInt ( $limit )
18
+    public function getRandomInt($limit)
19 19
     {
20
-        return random_int( 0, $limit );
20
+        return random_int(0, $limit);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
source/Symbols.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
      * @param string $symbols
22 22
      * @param int    $priority
23 23
      */
24
-    public function __construct ( $symbols, $priority = 100 )
24
+    public function __construct($symbols, $priority = 100)
25 25
     {
26
-        $this->setSymbols( $symbols );
27
-        $this->setPriority( $priority );
26
+        $this->setSymbols($symbols);
27
+        $this->setPriority($priority);
28 28
     }
29 29
 
30 30
     /**
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @throws InvalidArgumentException
36 36
      */
37
-    protected function setSymbols ( $symbols )
37
+    protected function setSymbols($symbols)
38 38
     {
39
-        if ( is_string( $symbols ) && strlen( $symbols ) > 0 ) {
39
+        if (is_string($symbols) && strlen($symbols) > 0) {
40 40
             $this->symbols = $symbols;
41 41
             return true;
42 42
         }
43
-        throw new InvalidArgumentException( 'Symbols must be a string, and contain at least one character' );
43
+        throw new InvalidArgumentException('Symbols must be a string, and contain at least one character');
44 44
     }
45 45
 
46 46
     /**
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @throws InvalidArgumentException
52 52
      */
53
-    protected function setPriority ( $priority )
53
+    protected function setPriority($priority)
54 54
     {
55
-        if ( is_int( $priority ) && $priority > 0 && $priority <= 100 ) {
55
+        if (is_int($priority) && $priority > 0 && $priority <= 100) {
56 56
             $this->priority = $priority;
57 57
             return true;
58 58
         }
59
-        throw new InvalidArgumentException( 'Priority must be interger and in the range from 1 to 100' );
59
+        throw new InvalidArgumentException('Priority must be interger and in the range from 1 to 100');
60 60
     }
61 61
 
62 62
     /**
63 63
      * @return int
64 64
      */
65
-    public function getPriority ()
65
+    public function getPriority()
66 66
     {
67 67
         return $this->priority;
68 68
     }
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return string
74 74
      */
75
-    public function getRandomSymbol ( MethodInterface $method = null )
75
+    public function getRandomSymbol(MethodInterface $method = null)
76 76
     {
77
-        $length = strlen( $this->symbols );
78
-        if ( $method ) {
79
-            $position = $method->getRandomInt( $length - 1 );
77
+        $length = strlen($this->symbols);
78
+        if ($method) {
79
+            $position = $method->getRandomInt($length - 1);
80 80
         } else {
81
-            $position = mt_rand( 0, $length - 1 );
81
+            $position = mt_rand(0, $length - 1);
82 82
         }
83
-        return $this->symbols[ $position ];
83
+        return $this->symbols[$position];
84 84
     }
85 85
 }
Please login to merge, or discard this patch.
source/Generator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param Options         $options
22 22
      * @param MethodInterface $method
23 23
      */
24
-    public function __construct ( Options $options, MethodInterface $method = null )
24
+    public function __construct(Options $options, MethodInterface $method = null)
25 25
     {
26 26
         $this->options = $options;
27 27
         $this->method = $method;
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @return MethodInterface
32 32
      */
33
-    public function getMethod ()
33
+    public function getMethod()
34 34
     {
35
-        if ( !$this->method instanceof MethodInterface ) {
35
+        if (!$this->method instanceof MethodInterface) {
36 36
             $this->method = new MethodMT();
37 37
         }
38 38
         return $this->method;
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @return string
43 43
      */
44
-    public function generate ()
44
+    public function generate()
45 45
     {
46 46
         $password = '';
47 47
         $map = $this->options->createHitRateMap();
48
-        $limit = count( $map ) - 1;
48
+        $limit = count($map) - 1;
49 49
         $length = $this->options->createLength();
50
-        for ( $i = 0; $i < $length; $i++ ) {
51
-            $position = $this->getMethod()->getRandomInt( $limit );
52
-            $symbols = $map[ $position ];
53
-            $password .= $symbols->getRandomSymbol( $this->getMethod() );
50
+        for ($i = 0; $i < $length; $i++) {
51
+            $position = $this->getMethod()->getRandomInt($limit);
52
+            $symbols = $map[$position];
53
+            $password .= $symbols->getRandomSymbol($this->getMethod());
54 54
         }
55 55
         return $password;
56 56
     }
Please login to merge, or discard this patch.
source/Length.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
      * @param int      $min
21 21
      * @param int|null $max
22 22
      */
23
-    public function __construct ( $min = 8, $max = null )
23
+    public function __construct($min = 8, $max = null)
24 24
     {
25
-        $this->setMin( $min );
26
-        $this->setMax( $max === null ? $min : $max );
25
+        $this->setMin($min);
26
+        $this->setMax($max === null ? $min : $max);
27 27
     }
28 28
 
29 29
     /**
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @throws InvalidArgumentException
35 35
      */
36
-    protected function setMin ( $min )
36
+    protected function setMin($min)
37 37
     {
38
-        if ( $min > 0 && $min <= 100 ) {
38
+        if ($min > 0 && $min <= 100) {
39 39
             $this->min = (int) $min;
40 40
             return true;
41 41
         }
42
-        throw new InvalidArgumentException( 'The min length should be from 1 to 100' );
42
+        throw new InvalidArgumentException('The min length should be from 1 to 100');
43 43
     }
44 44
 
45 45
     /**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @throws InvalidArgumentException
51 51
      */
52
-    protected function setMax ( $max )
52
+    protected function setMax($max)
53 53
     {
54
-        if ( $max > 0 && $max <= 100 ) {
54
+        if ($max > 0 && $max <= 100) {
55 55
             $this->max = (int) $max;
56 56
             return true;
57 57
         }
58
-        throw new InvalidArgumentException( 'The max length should be from 1 to 100' );
58
+        throw new InvalidArgumentException('The max length should be from 1 to 100');
59 59
     }
60 60
 
61 61
     /**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * @throws InvalidArgumentException
65 65
      */
66
-    public function getLength ()
66
+    public function getLength()
67 67
     {
68
-        if ( $this->min <= $this->max ) {
69
-            return mt_rand( $this->min, $this->max );
68
+        if ($this->min <= $this->max) {
69
+            return mt_rand($this->min, $this->max);
70 70
         }
71
-        throw new InvalidArgumentException( 'The min length should be less than the max' );
71
+        throw new InvalidArgumentException('The min length should be less than the max');
72 72
     }
73 73
 }
Please login to merge, or discard this patch.