Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  namespace Packback\Lti1p3;
   4  
   5  class LtiLineitem
   6  {
   7      private $id;
   8      private $score_maximum;
   9      private $label;
  10      private $resource_id;
  11      private $resource_link_id;
  12      private $tag;
  13      private $start_date_time;
  14      private $end_date_time;
  15  
  16      public function __construct(array $lineitem = null)
  17      {
  18          $this->id = $lineitem['id'] ?? null;
  19          $this->score_maximum = $lineitem['scoreMaximum'] ?? null;
  20          $this->label = $lineitem['label'] ?? null;
  21          $this->resource_id = $lineitem['resourceId'] ?? null;
  22          $this->resource_link_id = $lineitem['resourceLinkId'] ?? null;
  23          $this->tag = $lineitem['tag'] ?? null;
  24          $this->start_date_time = $lineitem['startDateTime'] ?? null;
  25          $this->end_date_time = $lineitem['endDateTime'] ?? null;
  26      }
  27  
  28      public function __toString()
  29      {
  30          // Additionally, includes the call back to filter out only NULL values
  31          return json_encode(array_filter([
  32              'id' => $this->id,
  33              'scoreMaximum' => $this->score_maximum,
  34              'label' => $this->label,
  35              'resourceId' => $this->resource_id,
  36              'resourceLinkId' => $this->resource_link_id,
  37              'tag' => $this->tag,
  38              'startDateTime' => $this->start_date_time,
  39              'endDateTime' => $this->end_date_time,
  40          ], '\Packback\Lti1p3\Helpers\Helpers::checkIfNullValue'));
  41      }
  42  
  43      /**
  44       * Static function to allow for method chaining without having to assign to a variable first.
  45       */
  46      public static function new()
  47      {
  48          return new LtiLineitem();
  49      }
  50  
  51      public function getId()
  52      {
  53          return $this->id;
  54      }
  55  
  56      public function setId($value)
  57      {
  58          $this->id = $value;
  59  
  60          return $this;
  61      }
  62  
  63      public function getLabel()
  64      {
  65          return $this->label;
  66      }
  67  
  68      public function setLabel($value)
  69      {
  70          $this->label = $value;
  71  
  72          return $this;
  73      }
  74  
  75      public function getScoreMaximum()
  76      {
  77          return $this->score_maximum;
  78      }
  79  
  80      public function setScoreMaximum($value)
  81      {
  82          $this->score_maximum = $value;
  83  
  84          return $this;
  85      }
  86  
  87      public function getResourceId()
  88      {
  89          return $this->resource_id;
  90      }
  91  
  92      public function setResourceId($value)
  93      {
  94          $this->resource_id = $value;
  95  
  96          return $this;
  97      }
  98  
  99      public function getResourceLinkId()
 100      {
 101          return $this->resource_link_id;
 102      }
 103  
 104      public function setResourceLinkId($value)
 105      {
 106          $this->resource_link_id = $value;
 107  
 108          return $this;
 109      }
 110  
 111      public function getTag()
 112      {
 113          return $this->tag;
 114      }
 115  
 116      public function setTag($value)
 117      {
 118          $this->tag = $value;
 119  
 120          return $this;
 121      }
 122  
 123      public function getStartDateTime()
 124      {
 125          return $this->start_date_time;
 126      }
 127  
 128      public function setStartDateTime($value)
 129      {
 130          $this->start_date_time = $value;
 131  
 132          return $this;
 133      }
 134  
 135      public function getEndDateTime()
 136      {
 137          return $this->end_date_time;
 138      }
 139  
 140      public function setEndDateTime($value)
 141      {
 142          $this->end_date_time = $value;
 143  
 144          return $this;
 145      }
 146  }