Skip to content

Commit 63569a4

Browse files
committed
MDL-79675 libraries: upgrade lti1p3 to v6.0.0
1 parent d3ad77e commit 63569a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1121
-1159
lines changed

lib/lti1p3/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ A library used for building IMS-certified LTI 1.3 tool providers in PHP.
44

55
This library is a fork of the [packbackbooks/lti-1-3-php-library](https://github.com/packbackbooks/lti-1-3-php-library), patched specifically for use in [Moodle](https://github.com/moodle/moodle).
66

7-
It is currently based on version [5.4.1 of the packbackbooks/lti-1-3-php-library](https://github.com/packbackbooks/lti-1-3-php-library/releases/tag/v5.4.1) library.
7+
It is currently based on version [6.0.0 of the packbackbooks/lti-1-3-php-library](https://github.com/packbackbooks/lti-1-3-php-library/releases/tag/v6.0.0) library.
88

99
The following changes are included so that the library may be used with Moodle:
1010

1111
* Replace the phpseclib dependency with openssl equivalent call in public key generation code.
1212

1313
Please see the original [README](https://github.com/packbackbooks/lti-1-3-php-library/blob/master/README.md) for more information about the upstream library.
14-
15-

lib/lti1p3/src/Concerns/Arrayable.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\Concerns;
4+
5+
use Packback\Lti1p3\Helpers\Helpers;
6+
7+
trait Arrayable
8+
{
9+
abstract public function getArray(): array;
10+
11+
public function toArray(): array
12+
{
13+
return Helpers::filterOutNulls($this->getArray());
14+
}
15+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\Concerns;
4+
5+
trait JsonStringable
6+
{
7+
use Arrayable;
8+
9+
public function __toString(): string
10+
{
11+
return json_encode($this->toArray());
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\DeepLinkResources;
4+
5+
use DateTime;
6+
use Packback\Lti1p3\Concerns\Arrayable;
7+
use Packback\Lti1p3\LtiException;
8+
9+
class DateTimeInterval
10+
{
11+
use Arrayable;
12+
public const ERROR_NO_START_OR_END = 'Either a start or end time must be specified.';
13+
public const ERROR_START_GT_END = 'The start time cannot be greater than end time.';
14+
15+
public function __construct(
16+
private ?DateTime $start = null,
17+
private ?DateTime $end = null
18+
) {
19+
$this->validateStartAndEnd();
20+
}
21+
22+
public static function new(): self
23+
{
24+
return new DateTimeInterval();
25+
}
26+
27+
public function getArray(): array
28+
{
29+
if (!isset($this->start) && !isset($this->end)) {
30+
throw new LtiException(self::ERROR_NO_START_OR_END);
31+
}
32+
33+
$this->validateStartAndEnd();
34+
35+
return [
36+
'startDateTime' => $this->start?->format(DateTime::ATOM),
37+
'endDateTime' => $this->end?->format(DateTime::ATOM),
38+
];
39+
}
40+
41+
public function setStart(?DateTime $start): self
42+
{
43+
$this->start = $start;
44+
45+
return $this;
46+
}
47+
48+
public function getStart(): ?DateTime
49+
{
50+
return $this->start;
51+
}
52+
53+
public function setEnd(?DateTime $end): self
54+
{
55+
$this->end = $end;
56+
57+
return $this;
58+
}
59+
60+
public function getEnd(): ?DateTime
61+
{
62+
return $this->end;
63+
}
64+
65+
/**
66+
* @throws LtiException
67+
*/
68+
private function validateStartAndEnd(): void
69+
{
70+
if (isset($this->start) && isset($this->end) && $this->start > $this->end) {
71+
throw new LtiException(self::ERROR_START_GT_END);
72+
}
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\DeepLinkResources;
4+
5+
trait HasDimensions
6+
{
7+
public function setWidth(?int $width): self
8+
{
9+
$this->width = $width;
10+
11+
return $this;
12+
}
13+
14+
public function getWidth(): ?int
15+
{
16+
return $this->width;
17+
}
18+
19+
public function setHeight(?int $height): self
20+
{
21+
$this->height = $height;
22+
23+
return $this;
24+
}
25+
26+
public function getHeight(): ?int
27+
{
28+
return $this->height;
29+
}
30+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\DeepLinkResources;
4+
5+
use Packback\Lti1p3\Concerns\Arrayable;
6+
7+
class Icon
8+
{
9+
use Arrayable, HasDimensions;
10+
11+
public function __construct(
12+
private string $url,
13+
private int $width,
14+
private int $height
15+
) {
16+
}
17+
18+
public static function new(string $url, int $width, int $height): self
19+
{
20+
return new Icon($url, $width, $height);
21+
}
22+
23+
public function getArray(): array
24+
{
25+
return [
26+
'url' => $this->url,
27+
'width' => $this->width,
28+
'height' => $this->height,
29+
];
30+
}
31+
32+
public function setUrl(string $url): self
33+
{
34+
$this->url = $url;
35+
36+
return $this;
37+
}
38+
39+
public function getUrl(): string
40+
{
41+
return $this->url;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Packback\Lti1p3\DeepLinkResources;
4+
5+
use Packback\Lti1p3\Concerns\Arrayable;
6+
7+
class Iframe
8+
{
9+
use Arrayable, HasDimensions;
10+
11+
public function __construct(
12+
private ?string $src = null,
13+
private ?int $width = null,
14+
private ?int $height = null
15+
) {
16+
}
17+
18+
public static function new(): self
19+
{
20+
return new Iframe();
21+
}
22+
23+
public function getArray(): array
24+
{
25+
return [
26+
'width' => $this->width,
27+
'height' => $this->height,
28+
'src' => $this->src,
29+
];
30+
}
31+
32+
public function setSrc(?string $src): self
33+
{
34+
$this->src = $src;
35+
36+
return $this;
37+
}
38+
39+
public function getSrc(): ?string
40+
{
41+
return $this->src;
42+
}
43+
}

0 commit comments

Comments
 (0)