Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied fixes from StyleCI #10

Merged
merged 1 commit into from Mar 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Action/ElasticLogsIndexAction.php
Expand Up @@ -6,15 +6,15 @@

/**
* A CRUD action class to implement the listing of all audit logs
* documents in elastic search
* documents in elastic search.
*/
class ElasticLogsIndexAction extends IndexAction
{

use IndexConfigTrait;

/**
* Renders the index action by searching all documents matching the URL conditions
* Renders the index action by searching all documents matching the URL conditions.
*
* @return void
*/
Expand Down Expand Up @@ -61,7 +61,6 @@ protected function _handle()
try {
$this->addTimeConstraints($request, $query);
} catch (\Exception $e) {

}

$subject = $this->_subject(['success' => true, 'query' => $query]);
Expand All @@ -75,7 +74,7 @@ protected function _handle()
}

/**
* Returns the Repository object to use
* Returns the Repository object to use.
*
* @return AuditStash\Model\Type\AuditLogsType;
*/
Expand All @@ -86,7 +85,7 @@ protected function _table()

/**
* Alters the query object to add the time constraints as they can be found in
* the request object
* the request object.
*
* @param Cake\Network\Request $request The request where query string params can be found
* @param Cake\ElasticSearch\Query $query The Query to add filters to
Expand Down
10 changes: 4 additions & 6 deletions src/Action/ElasticLogsViewAction.php
Expand Up @@ -2,23 +2,21 @@
namespace AuditStash\Action;

use Cake\ElasticSearch\TypeRegistry;
use Cake\Event\Event;
use Crud\Action\ViewAction;
use Crud\Traits\ViewTrait;
use Crud\Traits\ViewVarTrait;
use Crud\Event\Subject;
use Cake\Event\Event;

/**
* A CRUD action class to implement the view of all details of a single audit log event
* from elastic search
* from elastic search.
*/
class ElasticLogsViewAction extends ViewAction
{

use IndexConfigTrait;

/**
* Returns the Repository object to use
* Returns the Repository object to use.
*
* @return AuditStash\Model\Type\AuditLogsType;
*/
Expand All @@ -28,7 +26,7 @@ protected function _table()
}

/**
* Find a audit log by id
* Find a audit log by id.
*
* @param string $id Record id
* @param \Crud\Event\Subject $subject Event subject
Expand Down
3 changes: 2 additions & 1 deletion src/Action/IndexConfigTrait.php
@@ -1,13 +1,14 @@
<?php

namespace AuditStash\Action;

use DateTime;

trait IndexConfigTrait
{
/**
* Configures the index to use in elastic search by completing the placeholders with the current date
* if needed
* if needed.
*
* @param Cake\ElasticSearch\Type $repository
* @param Cake\Network\Request
Expand Down
6 changes: 2 additions & 4 deletions src/Event/AuditCreateEvent.php
Expand Up @@ -3,14 +3,12 @@
namespace AuditStash\Event;

/**
* Represents an audit log event for a newly created record
*
* Represents an audit log event for a newly created record.
*/
class AuditCreateEvent extends BaseEvent
{

/**
* Returns the type name of this event object
* Returns the type name of this event object.
*
* @return string
*/
Expand Down
9 changes: 4 additions & 5 deletions src/Event/AuditDeleteEvent.php
Expand Up @@ -6,8 +6,7 @@
use Datetime;

/**
* Represents an audit log event for a newly deleted record
*
* Represents an audit log event for a newly deleted record.
*/
class AuditDeleteEvent implements EventInterface
{
Expand All @@ -17,7 +16,7 @@ class AuditDeleteEvent implements EventInterface
}

/**
* Construnctor
* Construnctor.
*
* @param string $transationId The global transaction id
* @param mixed $id The primary key record that got deleted
Expand All @@ -30,11 +29,11 @@ public function __construct($transactionId, $id, $source, $parentSource = null)
$this->id = $id;
$this->source = $source;
$this->parentSource = $parentSource;
$this->timestamp = (new DateTime)->format(DateTime::ATOM);
$this->timestamp = (new DateTime())->format(DateTime::ATOM);
}

/**
* Returns the name of this event type
* Returns the name of this event type.
*
* @return string
*/
Expand Down
6 changes: 2 additions & 4 deletions src/Event/AuditUpdateEvent.php
Expand Up @@ -3,14 +3,12 @@
namespace AuditStash\Event;

/**
* Represents an audit log event for a modified created record
*
* Represents an audit log event for a modified created record.
*/
class AuditUpdateEvent extends BaseEvent
{

/**
* Returns the type name of this event object
* Returns the type name of this event object.
*
* @return string
*/
Expand Down
16 changes: 8 additions & 8 deletions src/Event/BaseEvent.php
Expand Up @@ -15,21 +15,21 @@ abstract class BaseEvent implements EventInterface
use SerializableEventTrait;

/**
* The array of changed properties for the entity
* The array of changed properties for the entity.
*
* @var array
*/
protected $changed;

/**
* The array of original properties before they got changed
* The array of original properties before they got changed.
*
* @var array
*/
protected $original;

/**
* Construnctor
* Construnctor.
*
* @param string $transationId The global transaction id
* @param mixed $id The primary key record that got deleted
Expand All @@ -44,11 +44,11 @@ public function __construct($transactionId, $id, $source, $changed, $original)
$this->source = $source;
$this->changed = $changed;
$this->original = $original;
$this->timestamp = (new DateTime)->format(DateTime::ATOM);
$this->timestamp = (new DateTime())->format(DateTime::ATOM);
}

/**
* Returns an array with the properties and their values before they got changed
* Returns an array with the properties and their values before they got changed.
*
* @return array
*/
Expand All @@ -58,7 +58,7 @@ public function getOriginal()
}

/**
* Returns an array with the properties and their values as they were changed
* Returns an array with the properties and their values as they were changed.
*
* @return array
*/
Expand All @@ -68,14 +68,14 @@ public function getChanged()
}

/**
* Returns the name of this event type
* Returns the name of this event type.
*
* @return string
*/
abstract public function getEventType();

/**
* Returns he array to be used for encoding this object as json
* Returns he array to be used for encoding this object as json.
*
* @return array
*/
Expand Down
31 changes: 15 additions & 16 deletions src/Event/BaseEventTrait.php
Expand Up @@ -3,55 +3,54 @@
namespace AuditStash\Event;

/**
* Implements most of the methods of the EventInterface
*
* Implements most of the methods of the EventInterface.
*/
trait BaseEventTrait
{
/**
* Global transaction id
* Global transaction id.
*
* @var string
*/
protected $transactionId;

/**
* Entity primary key
* Entity primary key.
*
* @var mixed
*/
protected $id;

/**
* Repository name
* Repository name.
*
* @var string
*/
protected $source;

/**
* Parent repository name
* Parent repository name.
*
* @var string
*/
protected $parentSource;

/**
* Time of event
* Time of event.
*
* @var string
*/
protected $timestamp;

/**
* Extra information to describe the event
* Extra information to describe the event.
*
* @var array
*/
protected $meta = [];

/**
* Returns the global transaction id in which this event is contained
* Returns the global transaction id in which this event is contained.
*
* @return string
*/
Expand All @@ -61,7 +60,7 @@ public function getTransactionId()
}

/**
* Returns the id of the entity that was created or altered
* Returns the id of the entity that was created or altered.
*
* @return mixed
*/
Expand All @@ -74,7 +73,7 @@ public function getId()
}

/**
* Returns the repository name in which the entity is
* Returns the repository name in which the entity is.
*
* @return string
*/
Expand All @@ -84,7 +83,7 @@ public function getSourceName()
}

/**
* Returns the repository name that triggered this event
* Returns the repository name that triggered this event.
*
* @return string
*/
Expand All @@ -94,7 +93,7 @@ public function getParentSourceName()
}

/**
* Sets the name of the repository taht trigered this event
* Sets the name of the repository taht trigered this event.
*
* @param string $source The repository name
* @return void
Expand All @@ -105,7 +104,7 @@ public function setParentSourceName($source)
}

/**
* Returns the time string in which this change happened
* Returns the time string in which this change happened.
*
* @return string
*/
Expand All @@ -115,7 +114,7 @@ public function getTimestamp()
}

/**
* Returns an array with meta information that can describe this event
* Returns an array with meta information that can describe this event.
*
* @return array
*/
Expand All @@ -125,7 +124,7 @@ public function getMetaInfo()
}

/**
* Sets the meta information that can describe this event
* Sets the meta information that can describe this event.
*
* @param array $meta The meta information to attach to the event
* @return void
Expand Down
10 changes: 4 additions & 6 deletions src/Event/SerializableEventTrait.php
Expand Up @@ -3,14 +3,12 @@
namespace AuditStash\Event;

/**
* Exposes basic functions for serializing event classes
*
* Exposes basic functions for serializing event classes.
*/
trait SerializableEventTrait
{

/**
* Returns the string representation of this object
* Returns the string representation of this object.
*
* @return string
*/
Expand All @@ -20,7 +18,7 @@ public function serialize()
}

/**
* Takes the string representation of this object so it can be reconstructed
* Takes the string representation of this object so it can be reconstructed.
*
* @param string $data serialized string
* @return void
Expand All @@ -34,7 +32,7 @@ public function unserialize($data)
}

/**
* Returns an array with the basic variables that should be json serialized
* Returns an array with the basic variables that should be json serialized.
*
* @return void
*/
Expand Down