Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
en0ma committed Apr 11, 2017
1 parent 734b9fd commit 60fc0c0
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 56 deletions.
10 changes: 10 additions & 0 deletions src/Commands/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ class MigrateCommand extends Command
{
use Resolver;

/**
* @var string
*/
private $directory = 'migrations';

/**
*
*/
protected function configure()
{
$this->setName('migrate')
->setDescription('Creates and versions dynamoDB tables.')
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
Expand Down
12 changes: 11 additions & 1 deletion src/Commands/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class SeedCommand extends Command
{
use Resolver;

/**
* @var string
*/
private $directory = 'seeds';


/**
*
*/
protected function configure()
{
$this
Expand All @@ -23,6 +29,10 @@ protected function configure()
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
Expand Down
52 changes: 26 additions & 26 deletions src/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,37 +89,37 @@ protected function setRCU(int $unit)
}

/**
Set the AttributeDefinition to an empty array.
This will make setting the attributes easier.
**/
* Set the AttributeDefinition to an empty array.
* This will make setting the attributes easier.
*/
private function setAttributeDefinitions()
{
if (!isset($this->tableParams['AttributeDefinitions'])) $this->tableParams['AttributeDefinitions'] = [];
}

/**
Set the Keyschema to an empty array.
This will make setting the primary key(s) easier.
**/
* Set the Keyschema to an empty array.
* This will make setting the primary key(s) easier.
*/
private function setKeySchema()
{
if (!isset($this->tableParams['KeySchema'])) $this->tableParams['KeySchema'] = [];
}

/**
Verify that the TableName param is set.
This is a mandatory param, just like the hash key.
**/
* Verify that the TableName param is set.
* This is a mandatory param, just like the hash key.
*/
private function isTableNameSet()
{
if (!isset($this->tableParams['TableName']))
throw new \Exception('Error: DynamoDB requires table name to be specified.');
}

/**
Very that a valid primary key was added with a corresponding valid
attribute name.
**/
* Very that a valid primary key was added with a corresponding valid
* attribute name.
*/
private function isHashSet()
{
$hashKeysFound = [];
Expand All @@ -142,17 +142,17 @@ private function isHashSet()
}

/**
Set the setProvisionedThroughput param to an empty array.
This will make setting up ReadCapacityUnit and WriteCapacityUnit up easier.
**/
* Set the setProvisionedThroughput param to an empty array.
* This will make setting up ReadCapacityUnit and WriteCapacityUnit up easier.
*/
private function setProvisionedThroughput()
{
if(!isset($this->tableParams['ProvisionedThroughput'])) $this->tableParams['ProvisionedThroughput'] = [];
}

/**
Show completion message, when migration is successful.
**/
* Show completion message, when migration is successful.
*/
private function displayCompletionMessage()
{
$className = get_class($this);
Expand All @@ -170,9 +170,9 @@ private function tableExist($table)
return in_array($table, $result['TableNames']);
}

/**
Create a new DynamoDB Table.
**/
/**
* Create a new DynamoDB Table.
*/
protected function create()
{
$this->isTableNameSet();
Expand All @@ -186,8 +186,8 @@ protected function create()
}

/**
Delete DynamoDB Table.
**/
* Delete DynamoDB Table.
*/
protected function delete()
{
$this->isTableNameSet();
Expand All @@ -197,8 +197,8 @@ protected function delete()
}

/**
Update dynamoDB Table.
**/
* Update dynamoDB Table.
*/
protected function update()
{
$this->isTableNameSet();
Expand All @@ -208,7 +208,7 @@ protected function update()
}

/**
Force migration files to define the up method.
**/
* Force migration files to define the up method.
*/
protected abstract function up();
}
10 changes: 7 additions & 3 deletions src/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Resolver
{
/**
* Get class names from files in migrations/seeds directory.
For any class found require it, so we can create an instance.
* For any class found require it, so we can create an instance.
*
* @param $dir
* @return array
Expand Down Expand Up @@ -38,8 +38,8 @@ protected function getClasses($dir)

/**
* Build class names from file name. This uses an underscore (_) convention.
Each file in eigther the migrations or seeds folder, uses an underscore naming
convention. eg: create_me_table => CreateMeTable (ClassName)
* Each file in eigther the migrations or seeds folder, uses an underscore naming
* convention. eg: create_me_table => CreateMeTable (ClassName)
*
* @param $file
* @return mixed
Expand All @@ -55,6 +55,10 @@ protected function buildClass($file)
return implode('', $fileNameParts);
}

/**
* @return mixed
* @throws \Exception
*/
protected function getConfig()
{
$configFile = 'rumble.yml';
Expand Down
53 changes: 27 additions & 26 deletions src/Seeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
abstract class Seeder
{
/**
DynamoDb table
**/
* DynamoDb table
*/
private $table;

/**
Aws dynamoDBClient
**/
* Aws dynamoDBClient
*/
private $dynamoDBClient;

/**
Aws Marshaler(makes formating data easy)
**/
* Aws Marshaler(makes formating data easy)
*/
private $marshaler;

/**
dynamoDB table items
**/
* dynamoDB table items
*/
private $items = [];

/**
Expand Down Expand Up @@ -62,18 +62,19 @@ protected function addItem($data)
}

/**
Verify that the TableName param is set.
This is a mandatory param, just like the hash key.
**/
* Verify that the TableName param is set.
* This is a mandatory param, just like the hash key.
* @throws \Exception
*/
private function isTableNameSet()
{
if (!$this->table)
throw new \Exception('Error: DynamoDB requires table name to be specified.');
}

/**
Verify that at least one item is added.
**/
* Verify that at least one item is added.
*/
private function atLeastOneItemExist()
{
if (count($this->items) == 0)
Expand All @@ -95,25 +96,25 @@ private function tableExist($table)


/**
Check if there are multiple items.
**/
* Check if there are multiple items.
*/
private function isBatchRequest()
{
return (count($this->items) > 1);
}

/**
Check to make sure batch items is not over limit (100).
**/
* Check to make sure batch items is not over limit (100).
*/
private function validateBatchItemsLimit()
{
if(count($this->items) > 100)
throw new \Exception('Maximum items that can be bacthed add is 100, limit exceeded.');
}

/**
Show completion message, when migration is successful.
**/
* Show completion message, when migration is successful.
*/
private function displayCompletionMessage()
{
$className = get_class($this);
Expand All @@ -122,11 +123,11 @@ private function displayCompletionMessage()
}

/**
Add a new item(s) to the specified dynamodb table.
If a single item is added, a simple putItem is used.
If multiple items are added, then the batchWriteItem is used.
NB: batchWriteItem can take maximum of 100 items per call.
**/
* Add a new item(s) to the specified dynamodb table.
* If a single item is added, a simple putItem is used.
* If multiple items are added, then the batchWriteItem is used.
* NB: batchWriteItem can take maximum of 100 items per call.
*/
protected function save()
{
$this->isTableNameSet();
Expand Down Expand Up @@ -162,7 +163,7 @@ protected function save()
}

/**
Force seed files to define the seed method.
**/
* Force seed files to define the seed method.
*/
protected abstract function seed();
}

0 comments on commit 60fc0c0

Please sign in to comment.