Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

includes/Validator/Password.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Validator;
3
4
use Redaxscript\Hash;
5
6
/**
7
 * children class to validate password
8
 *
9
 * @since 2.6.0
10
 *
11
 * @package Redaxscript
12
 * @category Validator
13
 * @author Henry Ruhs
14
 */
15
16
class Password implements ValidatorInterface
17
{
18
	/**
19
	 * validate the password
20
	 *
21
	 * @since 4.0.0
22
	 *
23
	 * @param string $password plain password
24
	 * @param string $hash hashed password
25
	 *
26
	 * @return bool
27
	 */
28
29 3
	public function validate(string $password = null, string $hash = null) : bool
30
	{
31 3
		$passwordHash = new Hash();
32 3
		return $password && $passwordHash->validate($password, $hash);
0 ignored issues
show
Bug Best Practice introduced by
The expression $password of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
33
	}
34
}