Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
base_native
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 5
72
0.00% covered (danger)
0.00%
0 / 1
 get_algo_name
n/a
0 / 0
n/a
0 / 0
0
 get_options
n/a
0 / 0
n/a
0 / 0
0
 check
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_algo_value
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 hash
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_supported
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
20
 needs_rehash
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\passwords\driver;
15
16abstract class base_native extends base
17{
18    /**
19    * Return the constant name for this driver's algorithm
20    *
21    * @link https://www.php.net/manual/en/password.constants.php
22    *
23    * @return string
24    */
25    abstract public function get_algo_name();
26
27    /**
28    * Return the options set for this driver instance
29    *
30    * @return array
31    */
32    abstract public function get_options();
33
34    /**
35    * {@inheritdoc}
36    */
37    public function check($password, $hash, $user_row = [])
38    {
39        return password_verify($password, $hash);
40    }
41
42    /**
43    * Return the value for this driver's algorithm
44    *
45    * @return integer
46    */
47    public function get_algo_value()
48    {
49        return constant($this->get_algo_name());
50    }
51
52    /**
53    * {@inheritdoc}
54    */
55    public function hash($password)
56    {
57        return password_hash($password, $this->get_algo_value(), $this->get_options());
58    }
59
60    /**
61    * {@inheritdoc}
62    */
63    public function is_supported()
64    {
65        return defined($this->get_algo_name()) && function_exists('password_hash') && function_exists('password_needs_rehash') && function_exists('password_verify');
66    }
67
68    /**
69    * {@inheritdoc}
70    */
71    public function needs_rehash($hash)
72    {
73        return password_needs_rehash($hash, $this->get_algo_value(), $this->get_options());
74    }
75}