Skip to content

Commit f624470

Browse files
Fixed indentation
1 parent 9c5a592 commit f624470

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+9556
-9559
lines changed

src/Parse/Internal/AddOperation.php

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,101 @@
88
/**
99
* Class AddOperation - FieldOperation for adding object(s) to array fields
1010
*
11-
* @package Parse
12-
* @author Fosco Marotto <fjm@fb.com>
11+
* @package Parse
12+
* @author Fosco Marotto <fjm@fb.com>
1313
*/
1414
class AddOperation implements FieldOperation
1515
{
1616

17-
/**
18-
* @var - Array with objects to add.
19-
*/
20-
private $objects;
17+
/**
18+
* @var - Array with objects to add.
19+
*/
20+
private $objects;
2121

22-
/**
23-
* Creates an AddOperation with the provided objects.
24-
*
25-
* @param array $objects Objects to add.
26-
*
27-
* @throws ParseException
28-
*/
29-
public function __construct($objects)
30-
{
31-
if (!is_array($objects)) {
32-
throw new ParseException("AddOperation requires an array.");
22+
/**
23+
* Creates an AddOperation with the provided objects.
24+
*
25+
* @param array $objects Objects to add.
26+
*
27+
* @throws ParseException
28+
*/
29+
public function __construct($objects)
30+
{
31+
if (!is_array($objects)) {
32+
throw new ParseException("AddOperation requires an array.");
33+
}
34+
$this->objects = $objects;
3335
}
34-
$this->objects = $objects;
35-
}
3636

37-
/**
38-
* Gets the objects for this operation.
39-
*
40-
* @return mixed
41-
*/
42-
public function getValue()
43-
{
44-
return $this->objects;
45-
}
46-
47-
/**
48-
* Returns associative array representing encoded operation.
49-
*
50-
* @return array
51-
*/
52-
public function _encode()
53-
{
54-
return array('__op' => 'Add',
55-
'objects' => ParseClient::_encode($this->objects, true));
56-
}
57-
58-
/**
59-
* Takes a previous operation and returns a merged operation to replace it.
60-
*
61-
* @param FieldOperation $previous Previous operation.
62-
*
63-
* @return FieldOperation Merged operation.
64-
* @throws ParseException
65-
*/
66-
public function _mergeWithPrevious($previous)
67-
{
68-
if (!$previous) {
69-
return $this;
70-
}
71-
if ($previous instanceof DeleteOperation) {
72-
return new SetOperation($this->objects);
37+
/**
38+
* Gets the objects for this operation.
39+
*
40+
* @return mixed
41+
*/
42+
public function getValue()
43+
{
44+
return $this->objects;
7345
}
74-
if ($previous instanceof SetOperation) {
75-
$oldList = $previous->getValue();
76-
return new SetOperation(
77-
array_merge((array)$oldList, (array)$this->objects)
78-
);
46+
47+
/**
48+
* Returns associative array representing encoded operation.
49+
*
50+
* @return array
51+
*/
52+
public function _encode()
53+
{
54+
return array('__op' => 'Add',
55+
'objects' => ParseClient::_encode($this->objects, true));
7956
}
80-
if ($previous instanceof AddOperation) {
81-
$oldList = $previous->getValue();
82-
return new SetOperation(
83-
array_merge((array)$oldList, (array)$this->objects)
84-
);
57+
58+
/**
59+
* Takes a previous operation and returns a merged operation to replace it.
60+
*
61+
* @param FieldOperation $previous Previous operation.
62+
*
63+
* @return FieldOperation Merged operation.
64+
* @throws ParseException
65+
*/
66+
public function _mergeWithPrevious($previous)
67+
{
68+
if (!$previous) {
69+
return $this;
70+
}
71+
if ($previous instanceof DeleteOperation) {
72+
return new SetOperation($this->objects);
73+
}
74+
if ($previous instanceof SetOperation) {
75+
$oldList = $previous->getValue();
76+
return new SetOperation(
77+
array_merge((array)$oldList, (array)$this->objects)
78+
);
79+
}
80+
if ($previous instanceof AddOperation) {
81+
$oldList = $previous->getValue();
82+
return new SetOperation(
83+
array_merge((array)$oldList, (array)$this->objects)
84+
);
85+
}
86+
throw new ParseException(
87+
'Operation is invalid after previous operation.'
88+
);
8589
}
86-
throw new ParseException(
87-
'Operation is invalid after previous operation.'
88-
);
89-
}
9090

91-
/**
92-
* Applies current operation, returns resulting value.
93-
*
94-
* @param mixed $oldValue Value prior to this operation.
95-
* @param mixed $obj Value being applied.
96-
* @param string $key Key this operation affects.
97-
*
98-
* @return array
99-
*/
100-
public function _apply($oldValue, $obj, $key)
101-
{
102-
if (!$oldValue) {
103-
return $this->objects;
91+
/**
92+
* Applies current operation, returns resulting value.
93+
*
94+
* @param mixed $oldValue Value prior to this operation.
95+
* @param mixed $obj Value being applied.
96+
* @param string $key Key this operation affects.
97+
*
98+
* @return array
99+
*/
100+
public function _apply($oldValue, $obj, $key)
101+
{
102+
if (!$oldValue) {
103+
return $this->objects;
104+
}
105+
return array_merge((array)$oldValue, (array)$this->objects);
104106
}
105-
return array_merge((array)$oldValue, (array)$this->objects);
106-
}
107107

108-
}
108+
}

0 commit comments

Comments
 (0)