Skip to content

Commit

Permalink
Remove support for proxying database adapters through a 'wrapper'
Browse files Browse the repository at this point in the history
The timed adapter was the only remaining implementation of this proxy pattern,
and was only actually printing statistics for `insert()` operations.

This was not that useful, and the overhead (e.g. on identifying dead code /
improving type safety / adding to adapters in future) of the proxy pattern was
quite high relative to the benefit. You can, of course, implement and register
your own adapter class as a proxy if you need it.
  • Loading branch information
acoulton committed Oct 21, 2022
1 parent 5eed89d commit 90c4e37
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 589 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Version History

**1.0.0** (DATE DATE DATE)
** UNRELEASED **

* Remove support for 'wrapping' database adapters, and the `TimedOutputAdapter`. The timed adapter was the only
remaining implementation of this proxy pattern, and was only actually printing statistics for `insert()` operations.
This was not that useful, and the overhead (e.g. on identifying dead code / improving type safety / adding to
adapters in future) of the proxy pattern was quite high relative to the benefit. You can, of course, implement and
register your own adapter class as a proxy if you need it.

**1.0.0 BETA** (2022-10-21)

* First release of the phinx-lightweight forked library
* Removed support for all database platforms/drivers other than MySQL over PDO
Expand Down
48 changes: 0 additions & 48 deletions src/Phinx/Db/Adapter/AdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ public static function instance()
'mysql' => 'Phinx\Db\Adapter\MysqlAdapter',
];

/**
* Class map of adapters wrappers, indexed by name.
*
* @var array
*/
protected $wrappers = [
'timed' => 'Phinx\Db\Adapter\TimedOutputAdapter',
];

/**
* Add or replace an adapter with a fully qualified class name.
*
Expand Down Expand Up @@ -128,45 +119,6 @@ public function getAdapter($name, array $options)
return new $class($options);
}

/**
* Add or replace a wrapper with a fully qualified class name.
*
* @throws \RuntimeException
* @param string $name
* @param string $class
* @return $this
*/
public function registerWrapper($name, $class)
{
if (!is_subclass_of($class, 'Phinx\Db\Adapter\WrapperInterface')) {
throw new \RuntimeException(sprintf(
'Wrapper class "%s" must be implement Phinx\\Db\\Adapter\\WrapperInterface',
$class
));
}
$this->wrappers[$name] = $class;

return $this;
}

/**
* Get a wrapper class by name.
*
* @throws \RuntimeException
* @param string $name
* @return string
*/
protected function getWrapperClass($name)
{
if (empty($this->wrappers[$name])) {
throw new \RuntimeException(sprintf(
'Wrapper "%s" has not been registered',
$name
));
}

return $this->wrappers[$name];
}

/**
* Get a wrapper instance by name.
Expand Down
304 changes: 0 additions & 304 deletions src/Phinx/Db/Adapter/AdapterWrapper.php

This file was deleted.

Loading

0 comments on commit 90c4e37

Please sign in to comment.