Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from baleen/repository-stack
Browse files Browse the repository at this point in the history
Repository Stack & Collection Refactor
  • Loading branch information
gsomoza committed Nov 6, 2015
2 parents 189a7bb + cdd1ea4 commit 7b491e8
Show file tree
Hide file tree
Showing 158 changed files with 3,954 additions and 2,797 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src_dir: lib
src_dir: src
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ php:

matrix:
allow_failures:
- php: 7.0
- php: hhvm
include:
- php: 5.5
Expand Down
18 changes: 9 additions & 9 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<!-- Uncomment the following when the tools are in ${basedir}/vendor/bin -->
<property name="toolsdir" value="${basedir}/vendor/bin/"/>

<fileset id="src" dir="${basedir}/lib">
<fileset id="src" dir="${basedir}/src">
<include name="**/*.php"/>
</fileset>

<fileset id="src-modified" dir="${basedir}/lib">
<fileset id="src-modified" dir="${basedir}/src">
<include name="**/*.php"/>
</fileset>

Expand Down Expand Up @@ -65,7 +65,7 @@
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${toolsdir}phploc" taskname="phploc">
<arg value="--count-tests" />
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
</exec>

<property name="phploc.done" value="true"/>
Expand All @@ -81,7 +81,7 @@
<arg path="${basedir}/build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="${basedir}/build/logs/phploc.xml" />
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
</exec>

<property name="phploc.done" value="true"/>
Expand All @@ -95,15 +95,15 @@
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
</exec>

<property name="pdepend.done" value="true"/>
</target>

<target name="phpmd" depends="prepare" description="PHP Mess Detector">
<exec executable="${toolsdir}phpmd" taskname="phpmd" failonerror="true">
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
<arg value="text" />
<arg value="${basedir}/build/phpmd.xml" />
</exec>
Expand All @@ -115,7 +115,7 @@
depends="prepare"
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpmd" taskname="phpmd" failonerror="true">
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
<arg value="xml" />
<arg value="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
Expand Down Expand Up @@ -152,7 +152,7 @@
unless="phpcpd.done"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcpd" taskname="phpcpd" failonerror="true">
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
</exec>

<property name="phpcpd.done" value="true"/>
Expand All @@ -165,7 +165,7 @@
<exec executable="${toolsdir}phpcpd" taskname="phpcpd" failonerror="true">
<arg value="--log-pmd" />
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/lib" />
<arg path="${basedir}/src" />
</exec>

<property name="phpcpd.done" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion build/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset name="PHP_CodeSniffer">
<description>PHP_CodeSniffer coding standard for this project.</description>

<file>./lib</file>
<file>./src</file>

<arg value="sp"/>

Expand Down
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@
"php": ">= 5.5",
"zendframework/zend-code": "^2.5",
"league/tactician": "^0.6.0",
"ebidtech/collection": "^2.0",
"symfony/event-dispatcher": "^2.7"
"symfony/event-dispatcher": "^2.7",
"doctrine/collections": "^1.3"
},
"autoload": {
"psr-4": {
"Baleen\\Migrations\\": "lib/"
"Baleen\\Migrations\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "*",
"phpunit/phpunit": "~4.1|^5.0",
"mockery/mockery": "^0.9.4",
"squizlabs/php_codesniffer": "2.*",
"phploc/phploc": "^2.1",
"phpmd/phpmd": "^2.2",
"sebastian/phpcpd": "^2.0",
"sphpdox/sphpdox": "dev-master"
}
},
"suggest": {
"baleen/storage-flysystem": "For storing migrations using Flysystem."
}
}
2 changes: 1 addition & 1 deletion docs/bin/generate-reference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ cd ..

rm -rf en/ref/Baleen
mkdir -p en/ref/Baleen
../vendor/bin/sphpdox process -o en/ref Baleen\\Migrations ../lib
../vendor/bin/sphpdox process -o en/ref Baleen\\Migrations ../src
find en/ref -name "*.rst" -exec bash -c 'mv "$1" "$(sed "s/\.rst$/.txt/" <<< "$1")"' - '{}' \;
16 changes: 9 additions & 7 deletions docs/en/examples/simple-usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ The following example illustrates how you can use Baleen migrations from within

// The repository is in charge of loading all available migrations.
$repository = new DirectoryRepository(__DIR__ . '/migrations');
$availableMigrations = $repository->getAllAvailableMigrations();
$available = $repository->getAllAvailableMigrations();

/* The Storage retrieves a list of versions that have already been run.
Here we're loading from a file, but it could also be a DB table, API call, etc. */
$storage = new FileStorage(__DIR__ . '/versions.txt');
$alreadyRun = $storage->readMigratedVersions();
// requires package "baleen/storage-flysystem"
$storage = new FlyStorage(__DIR__ . '/versions.txt');
$migrated = $storage->fetchAll();

$timelineFactory = new TimelineFactory();

/* The Timeline sorts migrations in order and runs them based on their status */
$timeline = new Timeline($availableMigrations, $alreadyRun);
$timeline = $timelineFactory->create($available, $migrated);

// Say we want to make sure all migrations up to and including v015 are UP:
$timeline->upTowards('v015');
Expand All @@ -31,9 +34,8 @@ The following example illustrates how you can use Baleen migrations from within

/* You can also run a single migration in any direction and pass custom arguments
to the Migration. */
use Baleen\Migration\RunOptions;
$options = new RunOptions(RunOptions::UP);
$options->setCustom([
use Baleen\Migration\Options;
$options = (new Options())->withCustom([
'notifyEmail' => 'jon@doe.me',
]);
$timeline->runSingle('v100', $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Baleen\\Migrations\\Event\\CanDispatchEventsTrait
:param $name:
:type $event: Event
:param $event:
:returns: Event
20 changes: 10 additions & 10 deletions docs/en/ref/Baleen/Migrations/Event/Timeline/CollectionEvent.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@ Baleen\\Migrations\\Event\\Timeline\\CollectionEvent

.. php:attr:: collection

protected LinkedVersions
protected Linked

.. php:attr:: options

protected Options
protected OptionsInterface

.. php:attr:: target

protected Version
protected VersionInterface

.. php:attr:: progress

protected Progress

.. php:method:: __construct(Version $target, Options $options, LinkedVersions $versions, Progress $progress = null)
.. php:method:: __construct(VersionInterface $target, OptionsInterface $options, Linked $versions, Progress $progress = null)

CollectionEvent constructor.

:type $target: Version
:type $target: VersionInterface
:param $target:
:type $options: Options
:type $options: OptionsInterface
:param $options:
:type $versions: LinkedVersions
:type $versions: Linked
:param $versions:
:type $progress: Progress
:param $progress:

.. php:method:: getOptions()

:returns: Options
:returns: OptionsInterface

.. php:method:: getCollection()

:returns: LinkedVersions
:returns: Linked

.. php:method:: getTarget()

:returns: Version
:returns: VersionInterface

.. php:method:: getProgress()

Expand Down
14 changes: 7 additions & 7 deletions docs/en/ref/Baleen/Migrations/Event/Timeline/MigrationEvent.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ Baleen\\Migrations\\Event\\Timeline\\MigrationEvent

.. php:attr:: options

protected Options
protected OptionsInterface

.. php:attr:: version

protected Version
protected VersionInterface

.. php:attr:: progress

protected Progress

.. php:method:: __construct(Version $version, Options $options, Progress $progress = null)
.. php:method:: __construct(VersionInterface $version, OptionsInterface $options, Progress $progress = null)

MigrationEvent constructor.

:type $version: Version
:type $version: VersionInterface
:param $version:
:type $options: Options
:type $options: OptionsInterface
:param $options:
:type $progress: Progress
:param $progress:

.. php:method:: getOptions()

:returns: Options
:returns: OptionsInterface

.. php:method:: getVersion()

:returns: Version
:returns: VersionInterface

.. php:method:: getProgress()

Expand Down
23 changes: 23 additions & 0 deletions docs/en/ref/Baleen/Migrations/Migration/AbstractMigration.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
------------------------------------------------
Baleen\\Migrations\\Migration\\AbstractMigration
------------------------------------------------

.. php:namespace: Baleen\\Migrations\\Migration

.. php:class:: AbstractMigration

A simple migration base class. To be used for examples and tests or extended by more
complex classes.

.. php:method:: getOptions()

:returns: OptionsInterface

.. php:method:: setOptions(OptionsInterface $options)

:type $options: OptionsInterface
:param $options:

.. php:method:: up()

.. php:method:: down()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Baleen\\Migrations\\Migration\\Capabilities\\OptionsAwareInterface

Interface OptionsAwareInterface.

.. php:method:: setOptions(Options $options)
.. php:method:: setOptions(OptionsInterface $options)

:type $options: Options
Receive an OptionsInterface instance

:type $options: OptionsInterface
:param $options:
:returns: void
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ Baleen\\Migrations\\Migration\\Capabilities\\TransactionAwareInterface

.. php:interface:: TransactionAwareInterface

Interface TransactionAwareInterface.
Indicates a migration can be handled within a transaction (commonly used in database migrations) and provides
methods for the different stages of a transaction.

.. php:method:: begin()

Called when the transaction should be begun.

:returns: void

.. php:method:: finish()

Called when the transaction should be finished.

:returns: void

.. php:method:: abort(Exception $e)

Called when the transaction should be cancelled.

:type $e: Exception
:param $e:
:returns: mixed
:returns: void
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Baleen\\Migrations\\Migration\\Command\\MigrateCommand

Class MigrateCommand.

.. php:method:: __construct(MigrationInterface $migration, Options $options)
.. php:method:: __construct(MigrationInterface $migration, OptionsInterface $options)

:type $migration: MigrationInterface
:param $migration:
:type $options: Options
:type $options: OptionsInterface
:param $options:

.. php:method:: getMigration()
Expand All @@ -26,9 +26,9 @@ Baleen\\Migrations\\Migration\\Command\\MigrateCommand

.. php:method:: getOptions()

:returns: Options
:returns: OptionsInterface

.. php:method:: setOptions(Options $options)
.. php:method:: setOptions(OptionsInterface $options)

:type $options: Options
:type $options: OptionsInterface
:param $options:
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ Baleen\\Migrations\\Migration\\Factory\\FactoryInterface

Interface for a Migrations Factory.

.. php:method:: create($class)
.. php:method:: create($class, $args = [])

Creates a Migration based on a class name.

:param $class:
:type $class: string
:param $class: The FQN of the migration class to be instantiated.
:type $args: array
:param $args: Constructor parameters.
:returns: \Baleen\Migrations\Migration\MigrationInterface
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Baleen\\Migrations\\Migration\\Factory\\SimpleFactory

.. php:class:: SimpleFactory

.. php:method:: create($class)
.. php:method:: create($class, $args = [])

:param $class:
:param $args:

0 comments on commit 7b491e8

Please sign in to comment.