Skip to content

Commit

Permalink
[SDK-3636] Add PSR-14 Event Dispatcher, for ultra customizable sessio…
Browse files Browse the repository at this point in the history
…n storage purposes (#646)

* [SDK-3636] Add PSR-14 Event Dispatcher, for ultra customizable session storage purposes

* test: Linter fixes
  • Loading branch information
evansims authored Sep 22, 2022
1 parent bcfdae7 commit fbef9f1
Show file tree
Hide file tree
Showing 10 changed files with 803 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Event/Psr14Store/Boot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Boot implements Auth0Event
{
private StoreInterface $store;
private string $prefix;

public function __construct(
StoreInterface $store,
string $prefix
) {
$this->store = $store;
$this->prefix = $prefix;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getPrefix(): string
{
return $this->prefix;
}

public function setPrefix(
string $prefix
): self {
$this->prefix = $prefix;
return $this;
}
}
37 changes: 37 additions & 0 deletions src/Event/Psr14Store/Clear.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Clear implements Auth0Event
{
private StoreInterface $store;
private ?bool $success = null;

public function __construct(
StoreInterface $store
) {
$this->store = $store;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getSuccess(): ?bool
{
return $this->success;
}

public function setSuccess(
?bool $success
): self {
$this->success = $success;
return $this;
}
}
32 changes: 32 additions & 0 deletions src/Event/Psr14Store/Defer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Defer implements Auth0Event
{
private StoreInterface $store;
private bool $state;

public function __construct(
StoreInterface $store,
bool $state
) {
$this->store = $store;
$this->state = $state;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getState(): bool
{
return $this->state;
}
}
45 changes: 45 additions & 0 deletions src/Event/Psr14Store/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Delete implements Auth0Event
{
private StoreInterface $store;
private string $key;
private ?bool $success = null;

public function __construct(
StoreInterface $store,
string $key
) {
$this->store = $store;
$this->key = $key;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getKey(): string
{
return $this->key;
}

public function getSuccess(): ?bool
{
return $this->success;
}

public function setSuccess(
?bool $success
): self {
$this->success = $success;
return $this;
}
}
24 changes: 24 additions & 0 deletions src/Event/Psr14Store/Destruct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Destruct implements Auth0Event
{
private StoreInterface $store;

public function __construct(
StoreInterface $store
) {
$this->store = $store;
}

public function getStore(): StoreInterface
{
return $this->store;
}
}
81 changes: 81 additions & 0 deletions src/Event/Psr14Store/Get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Get implements Auth0Event
{
private StoreInterface $store;
private ?bool $missed = null;
private ?bool $success = null;
private string $key;

/**
* @var mixed
*/
private $value;

public function __construct(
StoreInterface $store,
string $key
) {
$this->store = $store;
$this->key = $key;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getKey(): string
{
return $this->key;
}

/**
* @return mixed
*/
public function getValue()
{
return $this->value ?? null;
}

/**
* @param mixed $value
*/
public function setValue(
$value
): self {
$this->value = $value;
return $this;
}

public function getMissed(): ?bool
{
return $this->missed;
}

public function setMissed(
bool $missed
): self {
$this->missed = $missed;
return $this;
}

public function getSuccess(): ?bool
{
return $this->success;
}

public function setSuccess(
bool $success
): self {
$this->success = $success;
return $this;
}
}
65 changes: 65 additions & 0 deletions src/Event/Psr14Store/Set.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace Auth0\SDK\Event\Psr14Store;

use Auth0\SDK\Contract\Auth0Event;
use Auth0\SDK\Contract\StoreInterface;

final class Set implements Auth0Event
{
private StoreInterface $store;
private string $key;
private ?bool $success = null;

/**
* @var mixed
*/
private $value;

/**
* @param StoreInterface $store
* @param string $key
* @param mixed $value
*/
public function __construct(
StoreInterface $store,
string $key,
$value
) {
$this->store = $store;
$this->key = $key;
$this->value = $value;
}

public function getStore(): StoreInterface
{
return $this->store;
}

public function getKey(): string
{
return $this->key;
}

/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}

public function getSuccess(): ?bool
{
return $this->success;
}

public function setSuccess(
?bool $success
): self {
$this->success = $success;
return $this;
}
}
Loading

0 comments on commit fbef9f1

Please sign in to comment.