public function changePassword(string $newPassword, string $oldPassword): bool
    {
        //verfy password match
        if ($this->passwordUtility->verify($oldPassword, $this->password)) {

            //if match set new password
            $this->password = $this->passwordUtility->hash($newPassword);

            return true;
        }

        return false;
    }
public function changePassword(string $newPassword, string $oldPassword): bool
    {
        //verfy password match
        if ($this->passwordUtility->verify($oldPassword, $this->password)) {

            //if match set new password
            $this->password = $this->passwordUtility->hash($newPassword);

            return true;
        }

        return false;
    }
public function changePassword ( string $ newPassword , string $ oldPassword ) : bool { //verfy password match if ( $ this -> passwordUtility -> verify ( $ oldPassword , $ this -> password ) ) { //if match set new password $ this -> password = $ this -> passwordUtility -> hash ( $ newPassword ) ; return true ; } return false ; }
Change user password only after check old password.

<pre><code class="php">$password = new Password();

$user = new User($password);

$user->changePassword('newPassword', 'oldPassword');
</code></pre>

@param string $newPassword
@param string $oldPassword

@return bool
Change user password only after check old password .