Skip to content

Commit

Permalink
Classes docblocks added
Browse files Browse the repository at this point in the history
  • Loading branch information
todstoychev committed Nov 11, 2015
1 parent 2e7997a commit fb08c77
Show file tree
Hide file tree
Showing 25 changed files with 413 additions and 38 deletions.
6 changes: 6 additions & 0 deletions src/Console/RebuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
use Illuminate\Console\Command;
use Todstoychev\Icr\Processor;

/**
* Rebuild images in particular context.
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Console
*/
class RebuildCommand extends Command
{

Expand Down
14 changes: 14 additions & 0 deletions src/Exception/FileLimitExceededException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Todstoychev\Icr\Exception;

/**
* Handles file limit exceeded error
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class FileLimitExceededException extends \Exception
{

}
8 changes: 0 additions & 8 deletions src/Exception/FileLimitExeededException.php

This file was deleted.

6 changes: 6 additions & 0 deletions src/Exception/InvalidConfigurationValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Todstoychev\Icr\Exception;

/**
* Handles cofiguration value validation error
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class InvalidConfigurationValueException extends \Exception
{

Expand Down
6 changes: 6 additions & 0 deletions src/Exception/MandatoryConfigValueMissingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Todstoychev\Icr\Exception;

/**
* Handles mandatory configuration value missing error
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class MandatoryConfigValueMissingException extends \Exception
{

Expand Down
6 changes: 6 additions & 0 deletions src/Exception/NonAllowedFileExtensionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Todstoychev\Icr\Exception;

/**
* Handles non allowed file extension error
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class NonAllowedFileExtensionException extends \Exception
{

Expand Down
6 changes: 6 additions & 0 deletions src/Exception/NonAllowedMimeTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Todstoychev\Icr\Exception;

/**
* Handles non allowed mime type error
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class NonAllowedMimeTypeException extends \Exception
{

Expand Down
6 changes: 6 additions & 0 deletions src/Exception/NonExistingContextException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Todstoychev\Icr\Exception;

/**
* Handles non existing context name
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Exception
*/
class NonExistingContextException extends \Exception
{

Expand Down
16 changes: 15 additions & 1 deletion src/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function setConfig($config)
return $this;
}

/**
* Gets the uploads path parameter from configuration
*
* @return string
* @throws Exception\NonExistingArrayKeyException
*/
public function getUploadsPath()
{
if (!array_key_exists('uploads_path', $this->getConfig())) {
Expand All @@ -54,10 +60,18 @@ public function getUploadsPath()
return $this->config['uploads_path'];
}

/**
* Gets the context values array
*
* @param $context
*
* @return array
* @throws Exception\NonExistingContextException
*/
public function getContextValues($context)
{
if (!array_key_exists($context, $this->config)) {
throw new Exception\NonExsitingContextException("No context values found for '{$context}'");
throw new Exception\NonExistingContextException("No context values found for '{$context}'");
}

return $this->config[$context];
Expand Down
38 changes: 38 additions & 0 deletions src/Handler/ConfigurationValidationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
class ConfigurationValidationHandler extends AbstractHandler
{

/**
* Validates provided context name
*
* @param string $context
*
* @return ConfigurationValidationHandler
* @throws Exception\NonExistingContextException
*/
public function validateContext($context)
{
// Check is context set
Expand All @@ -24,6 +32,15 @@ public function validateContext($context)
return $this;
}

/**
* Validates configuration values for provided context
*
* @param string $context
*
* @return ConfigurationValidationHandler
* @throws Exception\InvalidConfigurationValueException
* @throws Exception\MandatoryConfigValueMissingException
*/
public function validateConfigValues($context)
{
foreach ($this->config[$context] as $values) {
Expand All @@ -36,6 +53,12 @@ public function validateConfigValues($context)
return $this;
}

/**
* Validetes provided image library driver
*
* @return ConfigurationValidationHandler
* @throws Exception\InvalidConfigurationValueException
*/
public function validateDriver()
{
if (
Expand All @@ -48,6 +71,14 @@ public function validateDriver()
return $this;
}

/**
* Validate key value
*
* @param string $keyName
* @param array $values
*
* @throws Exception\MandatoryConfigValueMissingException
*/
protected function validateKeyValues($keyName, array $values)
{
if (!array_key_exists($keyName, $values)) {
Expand All @@ -57,6 +88,13 @@ protected function validateKeyValues($keyName, array $values)
}
}

/**
* Validates value type
*
* @param array $values
*
* @throws Exception\InvalidConfigurationValueException
*/
protected function validateValuesType(array $values)
{
if (!in_array($values['operation'], StaticData\Operations::$allowedOperations)) {
Expand Down
23 changes: 23 additions & 0 deletions src/Handler/DeleteImageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

namespace Todstoychev\Icr\Handler;

/**
* Handles delete image operations
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Handler
*/
class DeleteImageHandler extends AbstractHandler
{
/**
* Delete only reized images and keeps the original image
*
* @param string $context
* @param string $fileName
*
* @throws \Todstoychev\Icr\Exception\NonExistingArrayKeyException
* @throws \Todstoychev\Icr\Exception\NonExistingContextException
*/
public function deleteImageSizes($context, $fileName)
{
$contextPath = public_path($this->getUploadsPath() . '/' . $context);
Expand All @@ -15,6 +30,14 @@ public function deleteImageSizes($context, $fileName)
}
}

/**
* Copletely deletes an image
*
* @param string $context
* @param string $fileName
*
* @throws \Todstoychev\Icr\Exception\NonExistingArrayKeyException
*/
public function deleteImage($context, $fileName)
{
$this->deleteImageSizes($context, $fileName);
Expand Down
16 changes: 16 additions & 0 deletions src/Handler/DirectoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
class DirectoryHandler extends AbstractHandler
{

/**
* Checks if directory exists. If directory is missing, creates it.
*
* @param string $context
*
* @return DirectoryHandler
* @throws \Todstoychev\Icr\Exception\NonExistingArrayKeyException
*/
public function checkAndCreateDirectories($context)
{
$path = public_path($this->getUploadsPath());
Expand All @@ -34,6 +42,14 @@ public function checkAndCreateDirectories($context)
return $this;
}

/**
* Delete all context files and directories in the directory tree
*
* @param string $context
*
* @return DirectoryHandler
* @throws \Todstoychev\Icr\Exception\NonExistingArrayKeyException
*/
public function deleteContextFilesAndDirectories($context)
{
foreach ($this->config[$context] as $sizeName => $values) {
Expand Down
7 changes: 7 additions & 0 deletions src/Handler/OpenImageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

use Todstoychev\Icr\Exception\ExtensionNotFoundException;

/**
* Handles existing image openning and creates the necessary image object, depending on the driver set
* in the configuration.
*
* @author Todor Todorov <[email protected]>
* @package Todstoychev\Icr\Handler
*/
class OpenImageHandler extends AbstractHandler
{
/**
Expand Down
Loading

0 comments on commit fb08c77

Please sign in to comment.