Skip to content

Commit

Permalink
FrontController refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
s3b4stian committed Sep 2, 2016
1 parent df7ec38 commit 6f97f49
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 180 deletions.
36 changes: 18 additions & 18 deletions src/Linna/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@
* Class a for autenticate users
*
* Utilize for login
*
*
* <?php
* $user = ''; //user from login page form
* $password = ''; //password from login page form
*
*
* $storedUser = ''; //user from stored user informations
* $storedPassword = ''; //password from stored user informations
* $storedId = ''; //user id from stored user informations
*
*
*
*
* $login = new Login();
* $login->login($user, $password, $storedUser, $storedPassword, $storedId);
*
*
* //redirect
*
*
*
*
* Utilize for check login
*
*
* <?php
* $login = new Login();
*
*
* if ($login->logged === true)
* {
* //do actions
* }
*
*
* Utilize for logout
*
*
* $login = new Login();
* $login->logout();
*
*
*/
class Login
{
Expand All @@ -59,7 +59,7 @@ class Login
public $data = array('user_name'=>'');

/**
* @var bool $logged Indicate login status, true or false
* @var bool $logged Indicate login status, true or false
*/
public $logged = false;

Expand All @@ -69,13 +69,13 @@ class Login
private $expire = 1800;

/**
* @var object $sessionInstance
* @var object $sessionInstance
*/
private $sessionInstance;

/**
* Constructor.
*
*
*/
public function __construct()
{
Expand All @@ -85,7 +85,7 @@ public function __construct()

/**
* Try to log user passed by param, return true if ok else false
*
*
* @param string $user
* @param string $password
* @param string $storedUser
Expand Down Expand Up @@ -121,7 +121,7 @@ public function login($user, $password, $storedUser = '', $storedPassword = '',

/**
* For do logout, delete login information from session
*
*
* @return bool
*/
public function logout()
Expand All @@ -135,7 +135,7 @@ public function logout()

/**
* Check if user is logged, get login data from session and update it
*
*
* @return bool
*/
private function refresh()
Expand Down
18 changes: 9 additions & 9 deletions src/Linna/Auth/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

/**
* Class for manage password, using PHP 5.5.0 password see php documentation for more information
*
*
* http://php.net/manual/en/ref.password.php.
*/
class Password
{
/**
* @var array $options An associative array containing options
*
*
* http://php.net/manual/en/password.constants.php
*/
protected $options = [
Expand All @@ -29,18 +29,18 @@ class Password

/**
* Constructor
*
*
*/
public function __construct()
{
}

/**
* Check if password matches a hash.
*
*
* @param string $hash
* @param string $password
*
*
* @return bool Result of password_verify PHP function.
*/
public function verify($password, $hash)
Expand All @@ -50,9 +50,9 @@ public function verify($password, $hash)

/**
* Create a password hash.
*
*
* @param string $password Password to be hashed.
*
*
* @return string Return the hashed password.
*/
public function hash($password)
Expand All @@ -65,9 +65,9 @@ public function hash($password)

/**
* Check if password need rehash
*
*
* @param string $hash Hash for check.
*
*
* @return boolean Return the hashed password.
*/
public function needsRehash($hash)
Expand Down
4 changes: 2 additions & 2 deletions src/Linna/Auth/ProtectedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

/**
* Help protect a controller with login.
*
*
*/
trait ProtectedController
{
/**
* Allow access to controller only if logged
*
*
* @param \Linna\Auth\Login $loginIstance
* @param string $redirect
*/
Expand Down
32 changes: 16 additions & 16 deletions src/Linna/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

/**
* PSR-4 Autoloader.
*
*
* An example of a general-purpose implementation that includes the optional
* functionality of allowing multiple base directories for a single namespace
* prefix.
*
*
* Given a foo-bar package of classes in the file system at the following
* paths ...
*
*
* /path/to/packages/foo-bar/
* src/
* Baz.php # Foo\Bar\Baz
Expand All @@ -30,35 +30,35 @@
* BazTest.php # Foo\Bar\BazTest
* Qux/
* QuuxTest.php # Foo\Bar\Qux\QuuxTest
*
*
* ... add the path to the class files for the \Foo\Bar\ namespace prefix
* as follows:
*
* <?php
* // instantiate the loader
* $loader = new \Example\Psr4AutoloaderClass;
*
*
* // register the autoloader
* $loader->register();
*
*
* $nm = [
* ['Foo\Bar', '/path/to/packages/foo-bar/src'],
* ['Foo\Bar', '/path/to/packages/foo-bar/tests']
* ];
*
*
* // register the base directories for the namespace prefix
* $loader->addNamespaces($nm);
*
*
*
*
* The following line would cause the autoloader to attempt to load the
* \Foo\Bar\Qux\Quux class from /path/to/packages/foo-bar/src/Qux/Quux.php:
*
*
* <?php
* new \Foo\Bar\Qux\Quux;
*
* The following line would cause the autoloader to attempt to load the
*
* The following line would cause the autoloader to attempt to load the
* \Foo\Bar\Qux\QuuxTest class from /path/to/packages/foo-bar/tests/Qux/QuuxTest.php:
*
*
* <?php
* new \Foo\Bar\Qux\QuuxTest;
*/
Expand All @@ -83,7 +83,7 @@ public function register()
/**
* Adds a base directory for a namespace prefix, accept an array of namespaces
* Utilize this for prevente multiple addNamespace() calls.
*
*
* @param array $namespaces The namespace prefix array.
*/
public function addNamespaces($namespaces)
Expand Down Expand Up @@ -143,7 +143,7 @@ public function loadClass($class)

/**
* Load the mapped file for a namespace prefix and relative class.
*
*
* @param string $prefix The namespace prefix.
* @param string $relativeClass The relative class name.
*
Expand Down Expand Up @@ -182,7 +182,7 @@ protected function loadMappedFile($prefix, $relativeClass)

/**
* If a file exists, require it from the file system.
*
*
* @param string $file The file to require.
*
* @return bool True if the file exists, false if not.
Expand Down
6 changes: 3 additions & 3 deletions src/Linna/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Database extends \PDO

/**
* Constructor
*
*
*/
public function __construct()
{
Expand All @@ -46,7 +46,7 @@ public function __construct()

/**
* Forbids the object clone
*
*
*/
private function __clone()
{
Expand All @@ -55,7 +55,7 @@ private function __clone()

/**
* Return te instance of database connection
*
*
* @return object
*/
public static function connect()
Expand Down
2 changes: 1 addition & 1 deletion src/Linna/Database/DomainObjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getId();

/**
* Set the id for this object
*
*
* @param type $objectId
*/
public function setId($objectId);
Expand Down
6 changes: 3 additions & 3 deletions src/Linna/Database/MapperAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ public function delete(DomainObjectInterface $domainObject)

/**
* Create a new instance of a DomainObject
*
*
* @return DomainObjectAbstract
*/
abstract protected function _create();

/**
* Insert the DomainObject to persistent storage
* Insert the DomainObject to persistent storage
*
* @param DomainObjectAbstract $domainObject
*/
abstract protected function _insert(DomainObjectInterface $domainObject);

/**
* Update the DomainObject in persistent storage
* Update the DomainObject in persistent storage
*
* @param DomainObjectAbstract $domainObject
*/
Expand Down
Loading

0 comments on commit 6f97f49

Please sign in to comment.