Skip to content

Commit

Permalink
Merge branch 'cs-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
redthor committed Aug 31, 2016
2 parents 5d37c6e + 1b40295 commit 7e8a7d9
Show file tree
Hide file tree
Showing 27 changed files with 145 additions and 159 deletions.
14 changes: 7 additions & 7 deletions src/AntiMattr/MongoDB/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(Version $version)
}

/**
* Get custom migration description
* Get custom migration description.
*
* @return string
*/
Expand Down Expand Up @@ -109,8 +109,8 @@ protected function throwIrreversibleMigrationException($message = null)
/**
* Print a warning message if the condition evalutes to TRUE.
*
* @param boolean $condition
* @param string $message
* @param bool $condition
* @param string $message
*/
public function warnIf($condition, $message = '')
{
Expand All @@ -124,8 +124,8 @@ public function warnIf($condition, $message = '')
/**
* Abort the migration if the condition evalutes to TRUE.
*
* @param boolean $condition
* @param string $message
* @param bool $condition
* @param string $message
*
* @throws AntiMattr\MongoDB\Migrations\Exception\AbortException
*/
Expand All @@ -141,8 +141,8 @@ public function abortIf($condition, $message = '')
/**
* Skip this migration (but not the next ones) if condition evalutes to TRUE.
*
* @param boolean $condition
* @param string $message
* @param bool $condition
* @param string $message
*
* @throws AntiMattr\MongoDB\Migrations\Exception\SkipException
*/
Expand Down
26 changes: 13 additions & 13 deletions src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
*/
class Statistics
{
const COUNT = "count";
const SIZE = "size";
const AVG_OBJ_SIZE = "avgObjSize";
const STORAGE_SIZE = "storageSize";
const NUM_EXTENTS = "numExtents";
const NINDEXES = "nindexes";
const LAST_EXTENT_SIZE = "lastExtentSize";
const PADDING_FACTOR = "paddingFactor";
const TOTAL_INDEX_SIZE = "totalIndexSize";

static public $metrics = array(
const COUNT = 'count';
const SIZE = 'size';
const AVG_OBJ_SIZE = 'avgObjSize';
const STORAGE_SIZE = 'storageSize';
const NUM_EXTENTS = 'numExtents';
const NINDEXES = 'nindexes';
const LAST_EXTENT_SIZE = 'lastExtentSize';
const PADDING_FACTOR = 'paddingFactor';
const TOTAL_INDEX_SIZE = 'totalIndexSize';

public static $metrics = array(
self::COUNT,
self::SIZE,
self::AVG_OBJ_SIZE,
Expand All @@ -38,7 +38,7 @@ class Statistics
self::NINDEXES,
self::LAST_EXTENT_SIZE,
self::PADDING_FACTOR,
self::TOTAL_INDEX_SIZE
self::TOTAL_INDEX_SIZE,
);

/**
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function getCollectionStats()
try {
if (!$data = $database->command(array('collStats' => $name))) {
$message = sprintf(
"Statistics not found for collection %s",
'Statistics not found for collection %s',
$name
);
throw new Exception($message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,24 @@
abstract class AbstractFileConfiguration extends Configuration
{
/**
* The configuration file used to load configuration information
* The configuration file used to load configuration information.
*
* @var string
*/
private $file;

/**
* Whether or not the configuration file has been loaded yet or not
* Whether or not the configuration file has been loaded yet or not.
*
* @var boolean
* @var bool
*/
private $loaded = false;

/**
* Load the information from the passed configuration file
* Load the information from the passed configuration file.
*
* @param string $file The path to the configuration file
*
* @return void
*
* @throws AntiMattr\MongoDB\Migrations\Exception\ConfigurationFileAlreadyLoadedException
*/
public function load($file)
Expand Down Expand Up @@ -76,7 +74,7 @@ public function getFile()
* load the given configuration file whether it be xml, yaml, etc. or something
* else.
*
* @param string $file The path to a configuration file.
* @param string $file The path to a configuration file
*/
abstract protected function doLoad($file);
}
69 changes: 34 additions & 35 deletions src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,49 @@ class Configuration
private $migrationsDatabase;

/**
* The migration database name to track versions in
* The migration database name to track versions in.
*
* @var string
*/
private $migrationsDatabaseName;

/**
* Flag for whether or not the migration collection has been created
* Flag for whether or not the migration collection has been created.
*
* @var boolean
* @var bool
*/
private $migrationCollectionCreated = false;

/**
* The migration collection name to track versions in
* The migration collection name to track versions in.
*
* @var string
*/
private $migrationsCollectionName = 'antimattr_migration_versions';

/**
* The path to a directory where new migration classes will be written
* The path to a directory where new migration classes will be written.
*
* @var string
*/
private $migrationsDirectory;

/**
* Namespace the migration classes live in
* Namespace the migration classes live in.
*
* @var string
*/
private $migrationsNamespace;

/**
* The path to a directory where mongo console scripts are
/**
* The path to a directory where mongo console scripts are.
*
* @var string
*/
private $migrationsScriptDirectory;

/**
* Used by Console Commands and Output Writer
* Used by Console Commands and Output Writer.
*
* @var string
*/
Expand Down Expand Up @@ -116,7 +116,7 @@ public function __construct(Connection $connection, OutputWriter $outputWriter =
}

/**
* Returns a timestamp version as a formatted date
* Returns a timestamp version as a formatted date.
*
* @param string $version
*
Expand Down Expand Up @@ -244,7 +244,7 @@ public function getMigrationsDirectory()
}

/**
* Set the migrations namespace
* Set the migrations namespace.
*
* @param string $migrationsNamespace The migrations namespace
*/
Expand Down Expand Up @@ -312,15 +312,15 @@ public function getName()
}

/**
* @return integer
* @return int
*/
public function getNumberOfAvailableMigrations()
{
return count($this->migrations);
}

/**
* @return integer
* @return int
*/
public function getNumberOfExecutedMigrations()
{
Expand All @@ -343,8 +343,8 @@ public function getOutputWriter()
* Register a single migration version to be executed by a AbstractMigration
* class.
*
* @param string $version The version of the migration in the format YYYYMMDDHHMMSS.
* @param string $class The migration class to execute for the version.
* @param string $version The version of the migration in the format YYYYMMDDHHMMSS
* @param string $class The migration class to execute for the version
*
* @return Version
*
Expand Down Expand Up @@ -393,9 +393,9 @@ public function registerMigrations(array $migrations)
* with the pattern VersionYYYYMMDDHHMMSS.php as the filename and registers
* them as migrations.
*
* @param string $path The root directory to where some migration classes live.
* @param string $path The root directory to where some migration classes live
*
* @return Version[] The array of migrations registered.
* @return Version[] The array of migrations registered
*/
public function registerMigrationsFromDirectory($path)
{
Expand All @@ -419,11 +419,11 @@ public function registerMigrationsFromDirectory($path)
/**
* Returns the Version instance for a given version in the format YYYYMMDDHHMMSS.
*
* @param string $version The version string in the format YYYYMMDDHHMMSS.
* @param string $version The version string in the format YYYYMMDDHHMMSS
*
* @return AntiMattr\MongoDB\Migrations\Version
*
* @throws AntiMattr\MongoDB\Migrations\Exception\UnknownVersionException Throws exception if migration version does not exist.
* @throws AntiMattr\MongoDB\Migrations\Exception\UnknownVersionException Throws exception if migration version does not exist
*/
public function getVersion($version)
{
Expand All @@ -439,19 +439,19 @@ public function getVersion($version)
*
* @param string $version
*
* @return boolean
* @return bool
*/
public function hasVersion($version)
{
return isset($this->migrations[$version]);
}

/**
* Check if a version has been migrated or not yet
* Check if a version has been migrated or not yet.
*
* @param AntiMattr\MongoDB\Migrations\Version $version
*
* @return boolean
* @return bool
*/
public function hasVersionMigrated(Version $version)
{
Expand Down Expand Up @@ -495,7 +495,7 @@ public function getCurrentVersion()
/**
* Returns the latest available migration version.
*
* @return string The version string in the format YYYYMMDDHHMMSS.
* @return string The version string in the format YYYYMMDDHHMMSS
*/
public function getLatestVersion()
{
Expand All @@ -508,7 +508,7 @@ public function getLatestVersion()
/**
* Create the migration collection to track migrations with.
*
* @return boolean Whether or not the collection was created.
* @return bool Whether or not the collection was created
*/
public function createMigrationCollection()
{
Expand All @@ -527,10 +527,10 @@ public function createMigrationCollection()
* Returns the array of migrations to executed based on the given direction
* and target version number.
*
* @param string $direction The direction we are migrating.
* @param string $to The version to migrate to.
* @param string $direction The direction we are migrating
* @param string $to The version to migrate to
*
* @return Version[] $migrations The array of migrations we can execute.
* @return Version[] $migrations The array of migrations we can execute
*/
public function getMigrationsToExecute($direction, $to)
{
Expand Down Expand Up @@ -560,17 +560,17 @@ public function getMigrationsToExecute($direction, $to)
* Check if we should execute a migration for a given direction and target
* migration version.
*
* @param string $direction The direction we are migrating.
* @param Version $version The Version instance to check.
* @param string $to The version we are migrating to.
* @param array $migrated Migrated versions array.
* @param string $direction The direction we are migrating
* @param Version $version The Version instance to check
* @param string $to The version we are migrating to
* @param array $migrated Migrated versions array
*
* @return boolean
* @return bool
*/
private function shouldExecuteMigration($direction, Version $version, $to, $migrated)
{
if ($direction === 'down') {
if ( ! in_array($version->getVersion(), $migrated)) {
if (!in_array($version->getVersion(), $migrated)) {
return false;
}

Expand All @@ -587,7 +587,7 @@ private function shouldExecuteMigration($direction, Version $version, $to, $migr
}

/**
* Validation that this instance has all the required properties configured
* Validation that this instance has all the required properties configured.
*
* @throws AntiMattr\MongoDB\Migrations\Exception\ConfigurationValidationException
*/
Expand Down Expand Up @@ -641,6 +641,5 @@ public function getDetailsMap()
'num_available_migrations' => $numAvailableMigrations,
'num_new_migrations' => $numNewMigrations,
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class XmlConfiguration extends AbstractFileConfiguration
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function doLoad($file)
{
Expand Down
Loading

0 comments on commit 7e8a7d9

Please sign in to comment.