LTI Integration Library  3.1.0
PHP class library for building LTI integrations
ConsumerNonce.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ceLTIc\LTI;
4 
14 {
15 
19  const MAX_NONCE_AGE = 30; // in minutes
20 
28  public static $maximumLength = 50;
29 
35  public $expires = null;
36 
42  private $consumer = null;
43 
49  private $value = null;
50 
57  public function __construct($consumer, $value = null)
58  {
59  $this->consumer = $consumer;
60  $this->value = substr($value, -self::$maximumLength);
61  $this->expires = time() + (self::MAX_NONCE_AGE * 60);
62  }
63 
69  public function load()
70  {
71  return $this->consumer->getDataConnector()->loadConsumerNonce($this);
72  }
73 
79  public function save()
80  {
81  return $this->consumer->getDataConnector()->saveConsumerNonce($this);
82  }
83 
89  public function getConsumer()
90  {
91  return $this->consumer;
92  }
93 
99  public function getValue()
100  {
101  return $this->value;
102  }
103 
104 }
__construct($consumer, $value=null)
Class constructor.
$expires
Timestamp for when the nonce value expires.
save()
Save a nonce value in the database.
static $maximumLength
Maximum length which can be stored.
getConsumer()
Get tool consumer.
Class to represent a tool consumer nonce.
load()
Load a nonce value from the database.
getValue()
Get outcome value.
const MAX_NONCE_AGE
Maximum age nonce values will be retained for (in minutes).