Skip to content

Commit

Permalink
Merge branch 'v6.0-beta' into lti-lib-v6
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhynds committed Dec 21, 2023
2 parents 05b84fb + 8b84a10 commit f6d0b9d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"scripts": {
"test": "phpunit",
"lint": [
"pint -v --test",
"pint --test",
"phpstan analyse"
],
"lint-fix": "pint -v"
Expand Down
10 changes: 5 additions & 5 deletions src/Interfaces/ILtiRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public function getClientId();

public function setClientId(string $clientId): ILtiRegistration;

public function getKeySetUrl();
public function getKeySetUrl(): ?string;

public function setKeySetUrl(string $keySetUrl): ILtiRegistration;

public function getAuthTokenUrl();
public function getAuthTokenUrl(): ?string;

public function setAuthTokenUrl(string $authTokenUrl): ILtiRegistration;
public function setAuthTokenUrl(?string $authTokenUrl): ILtiRegistration;

public function getAuthLoginUrl();
public function getAuthLoginUrl(): ?string;

public function setAuthLoginUrl(string $authLoginUrl): ILtiRegistration;

public function getAuthServer();
public function getAuthServer(): ?string;

public function setAuthServer(string $authServer): ILtiRegistration;

Expand Down
10 changes: 6 additions & 4 deletions src/Interfaces/ILtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace Packback\Lti1p3\Interfaces;

use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;

/** @internal */
interface ILtiServiceConnector
{
public function getAccessToken(ILtiRegistration $registration, array $scopes);
public function getAccessToken(ILtiRegistration $registration, array $scopes): string;

public function makeRequest(IServiceRequest $request);
public function makeRequest(IServiceRequest $request): ResponseInterface;

public function getResponseBody(Response $request): ?array;
public function getResponseBody(ResponseInterface $response): ?array;

public function getResponseHeaders(ResponseInterface $response): ?array;

public function makeServiceRequest(
ILtiRegistration $registration,
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/IServiceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function setAccessToken(string $accessToken): IServiceRequest;

public function setBody(string $body): IServiceRequest;

public function setPayload(array $payload): IServiceRequest;

public function setAccept(string $accept): IServiceRequest;

public function setContentType(string $contentType): IServiceRequest;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiDeployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct(
) {
}

public static function new($deployment_id): LtiDeployment
public static function new($deployment_id): self
{
return new LtiDeployment($deployment_id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/LtiLineitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public function __construct(?array $lineitem = null)
$this->grades_released = $lineitem['gradesReleased'] ?? null;
}

/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new(?array $lineItem = null): self
{
return new LtiLineitem($lineItem);
}

public function getArray(): array
{
return [
Expand All @@ -45,14 +53,6 @@ public function getArray(): array
];
}

/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new(?array $lineItem = null): self
{
return new LtiLineitem($lineItem);
}

public function getId()
{
return $this->id;
Expand Down
16 changes: 8 additions & 8 deletions src/LtiRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,48 @@ public function setClientId(string $clientId): self
return $this;
}

public function getKeySetUrl()
public function getKeySetUrl(): ?string
{
return $this->keySetUrl;
}

public function setKeySetUrl(string $keySetUrl): self
public function setKeySetUrl(?string $keySetUrl): self
{
$this->keySetUrl = $keySetUrl;

return $this;
}

public function getAuthTokenUrl()
public function getAuthTokenUrl(): ?string
{
return $this->authTokenUrl;
}

public function setAuthTokenUrl(string $authTokenUrl): self
public function setAuthTokenUrl(?string $authTokenUrl): self
{
$this->authTokenUrl = $authTokenUrl;

return $this;
}

public function getAuthLoginUrl()
public function getAuthLoginUrl(): ?string
{
return $this->authLoginUrl;
}

public function setAuthLoginUrl(string $authLoginUrl): self
public function setAuthLoginUrl(?string $authLoginUrl): self
{
$this->authLoginUrl = $authLoginUrl;

return $this;
}

public function getAuthServer()
public function getAuthServer(): ?string
{
return $this->authServer ?? $this->authTokenUrl;
}

public function setAuthServer(string $authServer): self
public function setAuthServer(?string $authServer): self
{
$this->authServer = $authServer;

Expand Down
8 changes: 7 additions & 1 deletion src/LtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getAccessToken(ILtiRegistration $registration, array $scopes): s
$accessTokenKey = $this->getAccessTokenCacheKey($registration, $scopes);
// Get access token from cache if it exists
$accessToken = $this->cache->getAccessToken($accessTokenKey);

if (isset($accessToken)) {
return $accessToken;
}
Expand Down Expand Up @@ -164,7 +165,12 @@ public function getAll(
while ($nextUrl) {
$response = $this->makeServiceRequest($registration, $scopes, $request);

$page_results = $key === null ? ($response['body'] ?? []) : ($response['body'][$key] ?? []);
if (isset($key)) {
$page_results = $response['body'][$key] ?? [];
} else {
$page_results = $response['body'] ?? [];
}

$results = array_merge($results, $page_results);

$nextUrl = $this->getNextUrl($response['headers']);
Expand Down

0 comments on commit f6d0b9d

Please sign in to comment.