2015-05-22 07:26:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Entity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Table(name="api_keys")
|
|
|
|
* @Entity
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
class ApiKey
|
2015-05-22 07:26:49 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="id", type="string", length=50)
|
|
|
|
* @Id
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="owner", type="string", length=150, nullable=true)
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $owner;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="calls_made", type="integer")
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $calls_made;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="created", type="integer")
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $created;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ApiKey constructor.
|
|
|
|
*/
|
2017-01-24 00:17:50 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->id = sha1(mt_rand(0, microtime(true)));
|
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
$this->calls_made = 0;
|
|
|
|
$this->created = time();
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getId(): string
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOwner(): string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->owner;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 07:26:49 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @param string $owner
|
2015-05-22 07:26:49 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function setOwner(string $owner)
|
|
|
|
{
|
|
|
|
$this->owner = $owner;
|
|
|
|
}
|
2015-05-22 07:26:49 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getCallsMade(): int
|
|
|
|
{
|
|
|
|
return $this->calls_made;
|
|
|
|
}
|
2015-05-22 07:26:49 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function callMade()
|
|
|
|
{
|
|
|
|
$this->calls_made++;
|
|
|
|
}
|
2015-05-22 07:26:49 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getCreated(): int
|
|
|
|
{
|
|
|
|
return $this->created;
|
|
|
|
}
|
2015-05-22 07:26:49 +00:00
|
|
|
}
|