Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Split the core #32

Merged
merged 8 commits into from
Jan 11, 2016
Merged
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
52 changes: 28 additions & 24 deletions Dal.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -36,17 +36,19 @@

namespace Hoa\Database;

use Hoa\Core;
use Hoa\Consistency;
use Hoa\Event;
use Hoa\Zformat;

/**
* Class \Hoa\Database\Dal.
*
* The higher class of the Database Abstract Layer. It wrappes all DAL.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Dal implements Core\Parameter\Parameterizable, Core\Event\Source
class Dal implements Zformat\Parameterizable, Event\Source
{
/**
* Abstract layer: DBA.
Expand Down Expand Up @@ -107,7 +109,7 @@ class Dal implements Core\Parameter\Parameterizable, Core\Event\Source
/**
* Parameter of \Hoa\Database\Dal.
*
* @var \Hoa\Core\Parameter
* @var \Hoa\Zformat\Parameter
*/
protected static $_parameters = null;

Expand All @@ -127,15 +129,15 @@ class Dal implements Core\Parameter\Parameterizable, Core\Event\Source
* @param array $connectionParameters The layer connection parameter.
* @return void
*/
private function __construct(Array $connectionParameters)
private function __construct(array $connectionParameters)
{
$this->_connectionParameters = $connectionParameters;

$id = $this->__id = self::$_id;
$event = 'hoa://Event/Database/' . $id;

Core\Event::register($event . ':opened', $this);
Core\Event::register($event . ':closed', $this);
Event::register($event . ':opened', $this);
Event::register($event . ':closed', $this);

return;
}
Expand All @@ -146,9 +148,9 @@ private function __construct(Array $connectionParameters)
* @param array $parameters Parameters.
* @return void
*/
public static function initializeParameters(Array $parameters = [])
public static function initializeParameters(array $parameters = [])
{
self::$_parameters = new Core\Parameter(
self::$_parameters = new Zformat\Parameter(
__CLASS__,
[],
[
Expand Down Expand Up @@ -187,7 +189,7 @@ public static function getInstance(
$dsn = null,
$username = null,
$password = null,
Array $driverOptions = []
array $driverOptions = []
) {
if (null === self::$_parameters) {
self::initializeParameters();
Expand Down Expand Up @@ -268,7 +270,7 @@ public static function getLastInstance()
/**
* Get parameters.
*
* @return \Hoa\Core\Parameter
* @return \Hoa\Zformat\Parameter
*/
public function getParameters()
{
Expand All @@ -295,16 +297,18 @@ private function open()
$dsn = 'sqlite:' . resolve($matches[1]);
}

$this->setDal(dnew(
'\Hoa\Database\Layer\\' . $dalName,
[$dsn, $username, $password, $driverOptions]
));
$this->setDal(
Consistency\Autoloader::dnew(
'Hoa\Database\Layer\\' . $dalName,
[$dsn, $username, $password, $driverOptions]
)
);

$id = $this->getId();
Core\Event::notify(
Event::notify(
'hoa://Event/Database/' . $id . ':opened',
$this,
new Core\Event\Bucket([
new Event\Bucket([
'id' => $id,
'dsn' => $dsn,
'username' => $username,
Expand All @@ -329,14 +333,14 @@ public function close()
self::$_id = null;
unset(self::$_instance[$id]);

Core\Event::notify(
Event::notify(
$event . ':closed',
$this,
new Core\Event\Bucket(['id' => $id])
new Event\Bucket(['id' => $id])
);

Core\Event::unregister($event . ':opened');
Core\Event::unregister($event . ':closed');
Event::unregister($event . ':opened');
Event::unregister($event . ':closed');

return true;
}
Expand Down Expand Up @@ -429,7 +433,7 @@ public function lastInsertId($name = null)
* @return \Hoa\Database\DalStatement
* @throws \Hoa\Database\Exception
*/
public function prepare($statement, Array $options = [])
public function prepare($statement, array $options = [])
{
return new DalStatement(
$this->getDal()->prepare(
Expand Down Expand Up @@ -513,7 +517,7 @@ public function getAvailableDrivers()
* @return array
* @throws \Hoa\Database\Exception
*/
public function setAttributes(Array $attributes)
public function setAttributes(array $attributes)
{
return $this->getDal()->setAttributes($attributes);
}
Expand Down
6 changes: 3 additions & 3 deletions DalStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* The higher class that represents a DAL statement.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class DalStatement
Expand Down Expand Up @@ -102,7 +102,7 @@ protected function getStatement()
* @return \Hoa\Database\DalStatement
* @throws \Hoa\Database\Exception
*/
public function execute(Array $bindParameters = [])
public function execute(array $bindParameters = [])
{
if (empty($bindParameters)) {
return $this->getStatement()->execute();
Expand Down
10 changes: 5 additions & 5 deletions Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -36,16 +36,16 @@

namespace Hoa\Database;

use Hoa\Core;
use Hoa\Exception as HoaException;

/**
* Class \Hoa\Database\Exception.
*
* Extending the \Hoa\Core\Exception class.
* Extending the \Hoa\Exception\Exception class.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Exception extends Core\Exception
class Exception extends HoaException
{
}
10 changes: 5 additions & 5 deletions IDal/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* Interface of a DAL wrapper.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
interface Wrapper
Expand All @@ -60,7 +60,7 @@ public function __construct(
$dsn,
$username,
$password,
Array $driverOptions = []
array $driverOptions = []
);

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ public function lastInsertId($name = null);
* @return \Hoa\Database\IDal\WrapperStatement
* @throws \Hoa\Database\Exception
*/
public function prepare($statement, Array $options = []);
public function prepare($statement, array $options = []);

/**
* Quote a string for use in a query.
Expand Down Expand Up @@ -163,7 +163,7 @@ public function getAvailableDrivers();
* @return array
* @throws \Hoa\Database\Exception
*/
public function setAttributes(Array $attributes);
public function setAttributes(array $attributes);

/**
* Set a specific attribute.
Expand Down
6 changes: 3 additions & 3 deletions IDal/WrapperStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* Interface of a DAL statement wrapper.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
interface WrapperStatement
Expand All @@ -54,7 +54,7 @@ interface WrapperStatement
* @return \Hoa\Database\IDal\WrapperStatement
* @throws \Hoa\Database\Exception
*/
public function execute(Array $bindParameters = []);
public function execute(array $bindParameters = []);

/**
* Bind a parameter to te specified variable name.
Expand Down
14 changes: 7 additions & 7 deletions Layer/Pdo/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -36,15 +36,15 @@

namespace Hoa\Database\Layer\Pdo;

use Hoa\Core;
use Hoa\Consistency;
use Hoa\Database;

/**
* Class \Hoa\Database\Layer\Pdo.
*
* Wrap PDO.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Pdo implements Database\IDal\Wrapper
Expand Down Expand Up @@ -72,7 +72,7 @@ public function __construct(
$dsn,
$username,
$password,
Array $driverOptions = []
array $driverOptions = []
) {
if (false === extension_loaded('pdo')) {
throw new Database\Exception(
Expand Down Expand Up @@ -191,7 +191,7 @@ public function lastInsertId($name = null)
* @return \Hoa\Database\Layer\Pdo\Statement
* @throws \Hoa\Database\Exception
*/
public function prepare($statement, Array $options = [])
public function prepare($statement, array $options = [])
{
$handle = $this->getConnection()->prepare($statement);

Expand Down Expand Up @@ -289,7 +289,7 @@ public function getAvailableDrivers()
* @return array
* @throws \Hoa\Database\Exception
*/
public function setAttributes(Array $attributes)
public function setAttributes(array $attributes)
{
$out = true;

Expand Down Expand Up @@ -363,4 +363,4 @@ public function getAttribute($attribute)
/**
* Flex entity.
*/
Core\Consistency::flexEntity('Hoa\Database\Layer\Pdo\Pdo');
Consistency::flexEntity('Hoa\Database\Layer\Pdo\Pdo');
6 changes: 3 additions & 3 deletions Layer/Pdo/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -43,7 +43,7 @@
*
* Wrap PDOStatement.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Statement implements Database\IDal\WrapperStatement
Expand Down Expand Up @@ -102,7 +102,7 @@ protected function getStatement()
* @return \Hoa\Database\Layer\Pdo\Statement
* @throws \Hoa\Database\Exception
*/
public function execute(Array $bindParameters = null)
public function execute(array $bindParameters = null)
{
if (false === $this->getStatement()->execute($bindParameters)) {
throw new Database\Exception(
Expand Down
4 changes: 2 additions & 2 deletions Query/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
* Copyright © 2007-2016, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* Build a DELETE query.
*
* @copyright Copyright © 2007-2015 Hoa community
* @copyright Copyright © 2007-2016 Hoa community
* @license New BSD License
*/
class Delete extends Where implements Dml
Expand Down
Loading