Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9367a7c

Browse files
committed
fixed CS
1 parent aad2b63 commit 9367a7c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/**
1818
* @author Elnur Abdurrakhimov <[email protected]>
19-
* @author Terje Bråten <[email protected]>
19+
* @author Terje Bråten <[email protected]>
2020
*/
2121
class BCryptPasswordEncoder extends BasePasswordEncoder
2222
{
@@ -33,8 +33,10 @@ class BCryptPasswordEncoder extends BasePasswordEncoder
3333
private static $prefix = null;
3434

3535
/**
36-
* @param SecureRandomInterface $secureRandom
37-
* @param int $cost
36+
* Constructor.
37+
*
38+
* @param SecureRandomInterface $secureRandom A SecureRandomInterface instance
39+
* @param integer $cost The algorithmic cost that should be used
3840
*
3941
* @throws \InvalidArgumentException if cost is out of range
4042
*/
@@ -44,13 +46,12 @@ public function __construct(SecureRandomInterface $secureRandom, $cost)
4446

4547
$cost = (int) $cost;
4648
if ($cost < 4 || $cost > 31) {
47-
throw new \InvalidArgumentException('Cost must be in the range of 4-31');
49+
throw new \InvalidArgumentException('Cost must be in the range of 4-31.');
4850
}
49-
$this->cost = sprintf("%02d", $cost);
51+
$this->cost = sprintf('%02d', $cost);
5052

5153
if (!self::$prefix) {
52-
self::$prefix = '$'.(version_compare(phpversion(), '5.3.7', '>=')
53-
? '2y' : '2a').'$';
54+
self::$prefix = '$'.(version_compare(phpversion(), '5.3.7', '>=') ? '2y' : '2a').'$';
5455
}
5556
}
5657

@@ -63,8 +64,7 @@ public function encodePassword($raw, $salt = null)
6364
return password_hash($raw, PASSWORD_BCRYPT, array('cost' => $this->cost));
6465
}
6566

66-
$salt = self::$prefix.$this->cost.'$'.
67-
$this->encodeSalt($this->getRawSalt());
67+
$salt = self::$prefix.$this->cost.'$'.$this->encodeSalt($this->getRawSalt());
6868
$encoded = crypt($raw, $salt);
6969
if (!is_string($encoded) || strlen($encoded) <= 13) {
7070
return false;
@@ -91,7 +91,8 @@ public function isPasswordValid($encoded, $raw, $salt = null)
9191
}
9292

9393
/**
94-
* Correctly encode the salt to be used by Bcrypt.
94+
* Encodes the salt to be used by Bcrypt.
95+
*
9596
* The blowfish/bcrypt algorithm used by PHP crypt expects a different
9697
* set and order of characters than the usual base64_encode function.
9798
* Regular b64: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
@@ -104,6 +105,7 @@ public function isPasswordValid($encoded, $raw, $salt = null)
104105
* of entropy.
105106
*
106107
* @param bytes $random a string of 16 random bytes
108+
*
107109
* @return string Properly encoded salt to use with php crypt function
108110
*
109111
* @throws \InvalidArgumentException if string of random bytes is too short
@@ -112,7 +114,7 @@ protected function encodeSalt($random)
112114
{
113115
$len = strlen($random);
114116
if ($len < 16) {
115-
throw new \InvalidArgumentException('The bcrypt salt needs 16 random bytes');
117+
throw new \InvalidArgumentException('The bcrypt salt needs 16 random bytes.');
116118
}
117119
if ($len > 16) {
118120
$random = substr($random, 0, 16);
@@ -121,7 +123,7 @@ protected function encodeSalt($random)
121123
$base64raw = str_replace('+', '.', base64_encode($random));
122124
$salt128bit = substr($base64raw, 0, 21);
123125
$lastchar = substr($base64raw, 21, 1);
124-
$lastchar = strtr($lastchar, 'AQgw','.Oeu');
126+
$lastchar = strtr($lastchar, 'AQgw', '.Oeu');
125127
$salt128bit .= $lastchar;
126128

127129
return $salt128bit;

0 commit comments

Comments
 (0)