Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Session] New Contract #193

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/contracts/session/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: PHP Session Contract
---

## Installation

```shell
composer require sonsofphp/session-contract
```

## Definitions

- **Session** - Session has a name and id that are used with a cookie.
- **Attribute** - A session can have zero or more attributes. Attributes are
stored using the session storage. Attributes will always be key/value.
- **Session Storage** - The session storage is what is used to store attributes
of that session.
2 changes: 2 additions & 0 deletions src/SonsOfPHP/Contract/Session/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.gitattributes export-ignore
/.gitignore export-ignore
2 changes: 2 additions & 0 deletions src/SonsOfPHP/Contract/Session/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/
19 changes: 19 additions & 0 deletions src/SonsOfPHP/Contract/Session/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2022 to Present Joshua Estes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions src/SonsOfPHP/Contract/Session/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Sons of PHP - Session Contract
=============================

## Learn More

* [Documentation][docs]
* [Contributing][contributing]
* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo]
* Get Help & Support using [Discussions][discussions]

[discussions]: https://github.com/orgs/SonsOfPHP/discussions
[mother-repo]: https://github.com/SonsOfPHP/sonsofphp
[contributing]: https://docs.sonsofphp.com/contributing/
[docs]: https://docs.sonsofphp.com/contracts/session/
[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ASession
[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ASession
10 changes: 10 additions & 0 deletions src/SonsOfPHP/Contract/Session/SessionExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\Session;

/**
* @author Joshua Estes <[email protected]>
*/
interface SessionExceptionInterface {}
10 changes: 10 additions & 0 deletions src/SonsOfPHP/Contract/Session/SessionHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\Session;

/**
* @author Joshua Estes <[email protected]>
*/
interface SessionHandlerInterface extends \SessionHandlerInterface {}
28 changes: 28 additions & 0 deletions src/SonsOfPHP/Contract/Session/SessionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\Session;

/**
* @author Joshua Estes <[email protected]>
*/
interface SessionInterface
{
/**
* Starts a session
*
* @throws SessionExceptionInterface
*/
public function start(): bool;

public function getName(): string;
public function setName(string $name): void;

public function getId(): string;
public function setId(string $id): void;

public function get(string $attribute, mixed $default = null): mixed;
public function set(string $attribute, mixed $value): mixed;
public function remove(string $attribute): mixed;
}
52 changes: 52 additions & 0 deletions src/SonsOfPHP/Contract/Session/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "sonsofphp/session-contract",
"type": "library",
"description": "",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"homepage": "https://github.com/SonsOfPHP/session-contract",
"license": "MIT",
"authors": [
{
"name": "Joshua Estes",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/SonsOfPHP/sonsofphp/issues",
"forum": "https://github.com/orgs/SonsOfPHP/discussions",
"docs": "https://docs.sonsofphp.com"
},
"autoload": {
"psr-4": {
"SonsOfPHP\\Contract\\Session\\": ""
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1"
},
"extra": {
"sort-packages": true,
"branch-alias": {
"dev-main": "0.3.x-dev"
}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/JoshuaEstes"
},
{
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
]
}
Loading