<?php

namespace App\Repositories;

use App\Models\User;

/**
 * Class UserRepository
 *
 * @package App\Repositories
 */
class UserRepository
{
    /**
     * @var \App\Repositories\UserRepository|null
     */
    protected static $instance = null;

    /**
     * @var \App\Models\User
     */
    protected $user;

    /**
     * UserRepository constructor.
     *
     * @param User|null $user
     */
    public function __construct(User $user = null)
    {
        $this->user = $user;
    }

    /**
     * Instance
     *
     * @param \App\Models\User $user
     * @return \App\Repositories\UserRepository
     */
    public static function instance(User $user = null)
    {
        if (is_null(static::$instance)) {
            static::$instance = new UserRepository($user);
        }

        return static::$instance;
    }

    /**
     * Hash password
     *
     * @param string $string
     * @return string
     */
    public function hashPassword($string)
    {
        return md5($string);
    }
}