php-censor/src/Model/Base/User.php

305 lines
5.9 KiB
PHP
Raw Normal View History

2018-03-09 19:00:53 +01:00
<?php
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
class User extends Model
{
/**
* @var string
*/
protected $tableName = 'user';
/**
* @var array
*/
protected $data = [
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => 0,
2018-03-09 19:00:53 +01:00
'name' => null,
'language' => null,
'per_page' => null,
'provider_key' => 'internal',
2018-03-09 19:00:53 +01:00
'provider_data' => null,
'remember_key' => null,
];
/**
* @return integer
*/
public function getId()
{
return (integer)$this->data['id'];
}
/**
* @param integer $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setId($value)
{
$this->validateNotNull('id', $value);
$this->validateInt('id', $value);
if ($this->data['id'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['id'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('id');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getEmail()
{
return $this->data['email'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setEmail($value)
{
$this->validateNotNull('email', $value);
$this->validateString('email', $value);
if ($this->data['email'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['email'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('email');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getHash()
{
return $this->data['hash'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setHash($value)
{
$this->validateNotNull('hash', $value);
$this->validateString('hash', $value);
if ($this->data['hash'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['hash'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('hash');
2018-03-09 19:00:53 +01:00
}
/**
* @return boolean
*/
public function getIsAdmin()
{
return (boolean)$this->data['is_admin'];
}
/**
* @param boolean $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setIsAdmin($value)
{
$this->validateNotNull('is_admin', $value);
$this->validateBoolean('is_admin', $value);
2018-03-11 06:13:28 +01:00
if ($this->data['is_admin'] === (integer)$value) {
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['is_admin'] = (integer)$value;
2018-03-11 06:13:28 +01:00
return $this->setModified('is_admin');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getName()
{
return $this->data['name'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setName($value)
{
$this->validateNotNull('name', $value);
$this->validateString('name', $value);
if ($this->data['name'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['name'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('name');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getLanguage()
{
return $this->data['language'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setLanguage($value)
{
if ($this->data['language'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['language'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('language');
2018-03-09 19:00:53 +01:00
}
/**
* @return integer
*/
public function getPerPage()
{
return (integer)$this->data['per_page'];
}
/**
* @param integer $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setPerPage($value)
{
$this->validateInt('per_page', $value);
if ($this->data['per_page'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['per_page'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('per_page');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getProviderKey()
{
return $this->data['provider_key'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setProviderKey($value)
{
$this->validateNotNull('provider_key', $value);
$this->validateString('provider_key', $value);
if ($this->data['provider_key'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['provider_key'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('provider_key');
2018-03-09 19:00:53 +01:00
}
/**
* @param string|null $key
*
* @return array|string|null
*/
public function getProviderData($key = null)
{
2018-03-11 06:13:28 +01:00
$data = json_decode($this->data['provider_data'], true);
2018-03-09 19:00:53 +01:00
$providerData = null;
if (is_null($key)) {
$providerData = $data;
} elseif (isset($data[$key])) {
$providerData = $data[$key];
}
return $providerData;
}
/**
* @param array $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setProviderData(array $value)
{
$this->validateNotNull('provider_data', $value);
$providerData = json_encode($value);
if ($this->data['provider_data'] === $providerData) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['provider_data'] = $providerData;
2018-03-11 06:13:28 +01:00
return $this->setModified('provider_data');
2018-03-09 19:00:53 +01:00
}
/**
* @return string
*/
public function getRememberKey()
{
return $this->data['remember_key'];
}
/**
* @param string $value
2018-03-11 06:13:28 +01:00
*
* @return boolean
2018-03-09 19:00:53 +01:00
*/
public function setRememberKey($value)
{
$this->validateString('remember_key', $value);
if ($this->data['remember_key'] === $value) {
2018-03-11 06:13:28 +01:00
return false;
2018-03-09 19:00:53 +01:00
}
$this->data['remember_key'] = $value;
2018-03-11 06:13:28 +01:00
return $this->setModified('remember_key');
2018-03-09 19:00:53 +01:00
}
}