-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed SessionRegistry to AbstractSession, Added ci configs & first …
…documentation
- Loading branch information
1 parent
a4bc680
commit e67af87
Showing
12 changed files
with
158 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
service_name: travis-ci | ||
coverage_clover: build/logs/clover.xml | ||
json_path: build/logs/coveralls-upload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
|
||
branches: | ||
only: | ||
- master | ||
- development | ||
- /^feature\/.+$/ | ||
|
||
before_script: | ||
- git checkout $TRAVIS_BRANCH | ||
- composer self-update | ||
- mkdir -p vendor/bin | ||
- composer install -o --prefer-dist --no-interaction | ||
- mkdir build/logs | ||
|
||
script: | ||
- php vendor/bin/phpunit -c build/ | ||
|
||
after_script: | ||
- php vendor/bin/coveralls -c ./.coveralls.yml -v --exclude-no-stmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,80 @@ | ||
[![Build Status](https://travis-ci.org/icehawk/session.svg?branch=master)](https://travis-ci.org/icehawk/session) | ||
[![Coverage Status](https://coveralls.io/repos/github/icehawk/session/badge.svg?branch=master)](https://coveralls.io/github/icehawk/session?branch=master) | ||
[![Latest Stable Version](https://poser.pugx.org/icehawk/session/v/stable)](https://packagist.org/packages/icehawk/session) | ||
[![Total Downloads](https://poser.pugx.org/icehawk/session/downloads)](https://packagist.org/packages/icehawk/session) | ||
[![Latest Unstable Version](https://poser.pugx.org/icehawk/session/v/unstable)](https://packagist.org/packages/icehawk/session) | ||
[![License](https://poser.pugx.org/icehawk/session/license)](https://packagist.org/packages/icehawk/session) | ||
|
||
# IceHawk\Session | ||
|
||
Session registry component for IceHawk framework | ||
|
||
## Intention | ||
|
||
This component is intended to wrap the super-global `$_SESSION` variable and give | ||
access to values by explicitly user-defined keys and value/return types | ||
and is therefor declared abstract. | ||
|
||
Furthermore it provides the registration and interfaces for data mappers on all, several or single keys, e.g. to reduce data overhead stored in session. | ||
|
||
## Usage | ||
|
||
### Extend the class `AbstractSession` | ||
|
||
```php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vendor\Project; | ||
|
||
use IceHawk\Session\AbstractSession; | ||
|
||
final class Session extends AbstractSession | ||
{ | ||
const KEY_SOME_STRING_VALUE = 'someStringValue'; | ||
|
||
public function getSomeStringValue() : string | ||
{ | ||
return $this->get( self::KEY_SOME_STRING_VALUE ); | ||
} | ||
|
||
public function setSomeStringValue( string $value ) | ||
{ | ||
$this->set( self::KEY_SOME_STRING_VALUE, $value ); | ||
} | ||
|
||
public function isSomeStringValueSet() : bool | ||
{ | ||
return $this->isset( self::KEY_SOME_STRING_VALUE ); | ||
} | ||
|
||
public function unsetSomeStringValue() | ||
{ | ||
$this->unset( self::KEY_SOME_STRING_VALUE ); | ||
} | ||
} | ||
``` | ||
|
||
### Work with values | ||
|
||
```php | ||
<?php declare(strict_types=1); | ||
|
||
namespace Vendor\Project; | ||
|
||
$session = new Session( $_SESSION ); | ||
|
||
# Set | ||
$session->setSomeStringValue( 'Hello world' ); | ||
|
||
# Isset | ||
if ( $session->isSomeStringValueSet() ) | ||
{ | ||
# Get | ||
$someString = $session->getSomeStringValue(); | ||
|
||
echo $someString . ' was set.'; | ||
} | ||
|
||
# Unset | ||
$session->unsetSomeStringValue(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters