Skip to content

More CS Fixes #88

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

Merged
merged 6 commits into from Apr 1, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Parse/Internal/AddOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
/**
* Class AddOperation - FieldOperation for adding object(s) to array fields.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class AddOperation implements FieldOperation
{
/**
* @var - Array with objects to add.
* Array with objects to add.
*
* @var array
*/
private $objects;

Expand Down
6 changes: 4 additions & 2 deletions src/Parse/Internal/AddUniqueOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
/**
* Class AddUniqueOperation - Operation to add unique objects to an array key.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class AddUniqueOperation implements FieldOperation
{
/**
* @var - Array containing objects to add.
* Array containing objects to add.
*
* @var array
*/
private $objects;

Expand Down
2 changes: 1 addition & 1 deletion src/Parse/Internal/DeleteOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Class DeleteOperation - FieldOperation to remove a key from an object.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class DeleteOperation implements FieldOperation
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parse/Internal/Encodable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Class Encodable - Interface for Parse Classes which provide an encode
* method.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
interface Encodable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parse/Internal/FieldOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Class FieldOperation - Interface for all Parse Field Operations.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
interface FieldOperation extends Encodable
{
Expand Down
6 changes: 4 additions & 2 deletions src/Parse/Internal/IncrementOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
/**
* Class IncrementOperation - Operation to increment numeric object key.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class IncrementOperation implements FieldOperation
{
/**
* @var int - Amount to increment by.
* Amount to increment by.
*
* @var int
*/
private $value;

Expand Down
79 changes: 53 additions & 26 deletions src/Parse/Internal/ParseRelationOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@
/**
* ParseRelationOperation - A class that is used to manage ParseRelation changes such as object add or remove.
*
* @author Mohamed Madbouli <[email protected]>
* @author Mohamed Madbouli <[email protected]>
*/
class ParseRelationOperation implements FieldOperation
{
/**
* @var string - The className of the target objects.
* The className of the target objects.
*
* @var string
*/
private $targetClassName;

/**
* @var array - Array of objects to add to this relation.
* Array of objects to add to this relation.
*
* @var array
*/
private $relationsToAdd = [];

/**
* @var array - Array of objects to remove from this relation.
* Array of objects to remove from this relation.
*
* @var array
*/
private $relationsToRemove = [];

Expand Down Expand Up @@ -126,10 +134,13 @@ public function _apply($oldValue, $object, $key)
return new ParseRelation($object, $key, $this->targetClassName);
} elseif ($oldValue instanceof ParseRelation) {
if ($this->targetClassName != null
&& $oldValue->getTargetClass() !== $this->targetClassName) {
throw new \Exception('Related object object must be of class '
.$this->targetClassName.', but '.$oldValue->getTargetClass()
.' was passed in.');
&& $oldValue->getTargetClass() !== $this->targetClassName
) {
throw new \Exception(
'Related object object must be of class '
.$this->targetClassName.', but '.$oldValue->getTargetClass()
.' was passed in.'
);
}

return $oldValue;
Expand All @@ -155,34 +166,50 @@ public function _mergeWithPrevious($previous)
}
if ($previous instanceof ParseRelationOperation) {
if ($previous->targetClassName != null
&& $previous->targetClassName != $this->targetClassName
&& $previous->targetClassName != $this->targetClassName
) {
throw new \Exception('Related object object must be of class '
.$this->targetClassName.', but '.$previous->targetClassName
.' was passed in.');
throw new \Exception(
'Related object object must be of class '
.$this->targetClassName.', but '.$previous->targetClassName
.' was passed in.'
);
}
$newRelationToAdd = self::convertToOneDimensionalArray(
$this->relationsToAdd);
$this->relationsToAdd
);
$newRelationToRemove = self::convertToOneDimensionalArray(
$this->relationsToRemove);
$this->relationsToRemove
);

$previous->addObjects($newRelationToAdd,
$previous->relationsToAdd);
$previous->removeObjects($newRelationToAdd,
$previous->relationsToRemove);
$previous->addObjects(
$newRelationToAdd,
$previous->relationsToAdd
);
$previous->removeObjects(
$newRelationToAdd,
$previous->relationsToRemove
);

$previous->removeObjects($newRelationToRemove,
$previous->relationsToAdd);
$previous->addObjects($newRelationToRemove,
$previous->relationsToRemove);
$previous->removeObjects(
$newRelationToRemove,
$previous->relationsToAdd
);
$previous->addObjects(
$newRelationToRemove,
$previous->relationsToRemove
);

$newRelationToAdd = self::convertToOneDimensionalArray(
$previous->relationsToAdd);
$previous->relationsToAdd
);
$newRelationToRemove = self::convertToOneDimensionalArray(
$previous->relationsToRemove);
$previous->relationsToRemove
);

return new ParseRelationOperation($newRelationToAdd,
$newRelationToRemove);
return new ParseRelationOperation(
$newRelationToAdd,
$newRelationToRemove
);
}
throw new \Exception('Operation is invalid after previous operation.');
}
Expand Down
9 changes: 6 additions & 3 deletions src/Parse/Internal/RemoveOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
* Class RemoveOperation - FieldOperation for removing object(s) from array
* fields.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class RemoveOperation implements FieldOperation
{
/**
* @var - Array with objects to remove.
* Array with objects to remove.
*
* @var array
*/
private $objects;

Expand Down Expand Up @@ -109,7 +111,8 @@ public function _apply($oldValue, $obj, $key)
if ($oldObject instanceof ParseObject) {
if ($newObject instanceof ParseObject
&& !$oldObject->isDirty()
&& $oldObject->getObjectId() == $newObject->getObjectId()) {
&& $oldObject->getObjectId() == $newObject->getObjectId()
) {
// found the object, won't add it.
} else {
$newValue[] = $oldObject;
Expand Down
10 changes: 7 additions & 3 deletions src/Parse/Internal/SetOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
/**
* Class SetOperation - Operation to set a value for an object key.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class SetOperation implements FieldOperation
{
/**
* @var - Value to set for this operation.
* Value to set for this operation.
*
* @var mixed
*/
private $value;

/**
* @var - If the value should be forced as object.
* If the value should be forced as object.
*
* @var bool
*/
private $isAssociativeArray;

Expand Down
39 changes: 19 additions & 20 deletions src/Parse/ParseACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,39 @@
* example, any user could read a particular object but only a particular set
* of users could write to that object.
*
* @author Mohamed Madbouli <[email protected]>
* @author Mohamed Madbouli <[email protected]>
*/
class ParseACL implements Encodable
{
/*
* @ignore
*/
const PUBLIC_KEY = '*';

/**
* @var array -
* @var array
*/
private $permissionsById = [];

/**
* @var bool -
* @var bool
*/
private $shared = false;

/**
* @var ParseUser -
* @var ParseUser
*/
private static $lastCurrentUser = null;

/**
* @var ParseACL -
* @var ParseACL
*/
private static $defaultACLWithCurrentUser = null;

/**
* @var ParseACL -
* @var ParseACL
*/
private static $defaultACL = null;

/**
* @var bool -
* @var bool
*/
private static $defaultACLUsesCurrentUser = false;

Expand Down Expand Up @@ -69,7 +72,6 @@ public static function createACLWithUser($user)
* @throws \Exception
*
* @return ParseACL
* @ignore
*/
public static function _createACLFromJSON($data)
{
Expand All @@ -81,11 +83,13 @@ public static function _createACLFromJSON($data)
foreach ($permissions as $accessType => $value) {
if ($accessType !== 'read' && $accessType !== 'write') {
throw new \Exception(
'Tried to create an ACL with an invalid permission type.');
'Tried to create an ACL with an invalid permission type.'
);
}
if (!is_bool($value)) {
throw new \Exception(
'Tried to create an ACL with an invalid permission value.');
'Tried to create an ACL with an invalid permission value.'
);
}
$acl->setAccess($accessType, $id, $value);
}
Expand All @@ -98,7 +102,6 @@ public static function _createACLFromJSON($data)
* Return if ParseACL shared or not.
*
* @return bool
* @ignore
*/
public function _isShared()
{
Expand All @@ -109,16 +112,12 @@ public function _isShared()
* Set shared for ParseACL.
*
* @param bool $shared
* @ignore
*/
public function _setShared($shared)
{
$this->shared = $shared;
}

/**
* @ignore
*/
public function _encode()
{
if (empty($this->permissionsById)) {
Expand Down Expand Up @@ -438,7 +437,8 @@ private static function validateRoleState($role)
{
if (!$role->getObjectId()) {
throw new \Exception(
"Roles must be saved to the server before they can be used in an ACL.");
"Roles must be saved to the server before they can be used in an ACL."
);
}
}

Expand Down Expand Up @@ -538,7 +538,6 @@ public static function setDefaultACL($acl, $withAccessForCurrentUser)
* Get the defaultACL.
*
* @return ParseACL
* @ignore
*/
public static function _getDefaultACL()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parse/ParseAggregateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* ParseAggregateException - Multiple error condition.
*
* @author Fosco Marotto <[email protected]>
* @author Fosco Marotto <[email protected]>
*/
class ParseAggregateException extends ParseException
{
Expand Down
Loading