/**
  * User constructor.
  * Checks if the user is logged in
  * @param int $id
  * @since 0.1.0 Now allows creating user object by id
  * @since 0.0.1
  */
 public function __construct($id = null)
 {
     if (!empty($id)) {
         /** @var UserEntity $entity */
         $entity = self::find($id);
         $this->id = $id;
         $this->entity = $entity;
     } else {
         $fingerprint = Session::get('fingerprint');
         $this->id = Session::get('user_id');
         if ($fingerprint != null && $this->id != null) {
             /**
              * @var UserEntity $temp_entity
              */
             $temp_entity = self::find($this->id);
             if ($temp_entity != null && $fingerprint == Session::getFingerprint(md5($temp_entity->getPassword()))) {
                 $this->entity = $temp_entity;
             }
         }
     }
 }