Skip to content

Commit

Permalink
Initial stub commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmann committed Nov 19, 2016
0 parents commit 1eeeab4
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
composer.lock
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Eric Mann <[email protected]>

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.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PHP Sessionz
============
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ericmann/sessionz",
"description": "PHP Session Manager Interface",
"type": "library",
"version": "1.0.0",
"license": "MIT",
"authors": [
{
"name": "Eric Mann",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=5.6.28"
},
"require-dev": {
"phpunit/phpunit": "^5.6"
}
}
65 changes: 65 additions & 0 deletions php/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
namespace EAMann\Sessionz;

abstract class Handler {
/**
* Action to be run when closing the current session.
*
* @param callable $next
*
* @return bool
*/
abstract public function close($next);

/**
* Action to be run when destroying a session based on its ID.
*
* @param string $id
* @param callable $next
*
* @return bool
*/
abstract public function destroy($id, $next);

/**
* Action to be run when cleaning up expired sessions.
*
* @param int $maxlifetime
* @param callable $next
*
* @return bool
*/
abstract public function gc($maxlifetime, $next);

/**
* Action to be run when creating a new session.
*
* @param string $path
* @param string $name
* @param callable $next
*
* @return bool
*/
abstract public function open($path, $name, $next);

/**
* Action to be run when reading session data from storage.
*
* @param string $id
* @param callable $next
*
* @return string
*/
abstract public function read($id, $next);

/**
* Action to be run when writing session data to storage.
*
* @param string $id
* @param string $data
* @param callable $next
*
* @return bool
*/
abstract public function write($id, $data, $next);
}
69 changes: 69 additions & 0 deletions php/Handlers/EncryptionHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
namespace EAMann\Sessionz\Handlers;

use EAMann\Sessionz\Handler;

class MemcacheHandler extends Handler {

/**
* Noop function for closing a session.
*
* @param callable $next
*
* @return bool
*/
public function close($next)
{
return $next();
}

/**
* Noop function for destroying a session.
*
* @param string $id
* @param callable $next
*
* @return bool
*/
public function destroy($id, $next)
{
return $next( $id );
}

/**
* Noop function for cleaning up expired sessions.
*
* @param int $maxlifetime
* @param callable $next
*
* @return bool
*/
public function gc($maxlifetime, $next)
{
return $next( $maxlifetime );
}

/**
* Noop function for creating a session.
*
* @param string $path
* @param string $name
* @param callable $next
*
* @return bool
*/
public function open($path, $name, $next)
{
return $next( $path, $name );
}

public function read($id, $next)
{
// TODO: Implement read() method.
}

public function write($id, $data, $next)
{
// TODO: Implement write() method.
}
}
68 changes: 68 additions & 0 deletions php/Handlers/MemcacheHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
namespace EAMann\Sessionz\Handlers;

use EAMann\Sessionz\Handler;

class MemcacheHandler extends Handler {

/**
* @param callable $next
* @return mixed
*/
public function close($next)
{
// TODO: Implement close() method.
}

/**
* @param string $id
* @param callable $next
* @return mixed
*/
public function destroy($id, $next)
{
// TODO: Implement destroy() method.
}

/**
* @param int $maxlifetime
* @param callable $next
* @return mixed
*/
public function gc($maxlifetime, $next)
{
// TODO: Implement gc() method.
}

/**
* @param string $path
* @param string $name
* @param callable $next
* @return mixed
*/
public function open($path, $name, $next)
{
// TODO: Implement open() method.
}

/**
* @param string $id
* @param callable $next
* @return mixed
*/
public function read($id, $next)
{
// TODO: Implement read() method.
}

/**
* @param string $id
* @param string $data
* @param callable $next
* @return mixed
*/
public function write($id, $data, $next)
{
// TODO: Implement write() method.
}
}
68 changes: 68 additions & 0 deletions php/Handlers/MemoryHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
namespace EAMann\Sessionz\Handlers;

use EAMann\Sessionz\Handler;

class MemoryHandler extends Handler {

/**
* @param callable $next
* @return mixed
*/
public function close($next)
{
// TODO: Implement close() method.
}

/**
* @param string $id
* @param callable $next
* @return mixed
*/
public function destroy($id, $next)
{
// TODO: Implement destroy() method.
}

/**
* @param int $maxlifetime
* @param callable $next
* @return mixed
*/
public function gc($maxlifetime, $next)
{
// TODO: Implement gc() method.
}

/**
* @param string $path
* @param string $name
* @param callable $next
* @return mixed
*/
public function open($path, $name, $next)
{
// TODO: Implement open() method.
}

/**
* @param string $id
* @param callable $next
* @return mixed
*/
public function read($id, $next)
{
// TODO: Implement read() method.
}

/**
* @param string $id
* @param string $data
* @param callable $next
* @return mixed
*/
public function write($id, $data, $next)
{
// TODO: Implement write() method.
}
}
Loading

0 comments on commit 1eeeab4

Please sign in to comment.