@@ -83,12 +83,12 @@ |
||
| 83 | 83 | $this->mapTopic($topic); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - foreach($topic->getField('comments', []) as $i => $comment) { |
|
| 86 | + foreach ($topic->getField('comments', []) as $i => $comment) { |
|
| 87 | 87 | if ($comment->getField('created_time') >= $startDate && $comment->getField('created_time') <= $endDate) { |
| 88 | 88 | $this->mapComment($comment, $topic); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - foreach($comment->getField('comments', []) as $j=>$reply) { |
|
| 91 | + foreach ($comment->getField('comments', []) as $j=>$reply) { |
|
| 92 | 92 | if ($reply->getField('created_time') >= $startDate && $reply->getField('created_time') <= $endDate) { |
| 93 | 93 | $this->mapReply($reply, $topic, $comment); |
| 94 | 94 | } |
@@ -10,18 +10,18 @@ |
||
| 10 | 10 | public function getFunctions() |
| 11 | 11 | { |
| 12 | 12 | return [ |
| 13 | - new ExpressionFunction('strlen', function ($str) { |
|
| 13 | + new ExpressionFunction('strlen', function($str) { |
|
| 14 | 14 | return sprintf('(is_string(%1$s) ? strlen(%1$s) : %1$s)', $str); |
| 15 | - }, function ($arguments, $str) { |
|
| 15 | + }, function($arguments, $str) { |
|
| 16 | 16 | if (!is_string($str)) { |
| 17 | 17 | return $str; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | return strlen($str); |
| 21 | 21 | }), |
| 22 | - new ExpressionFunction('contains', function ($haystack, $needle) { |
|
| 22 | + new ExpressionFunction('contains', function($haystack, $needle) { |
|
| 23 | 23 | return sprintf('(strpos(%1$s, %2$s) !== false) ? true : false', $haystack, $needle); |
| 24 | - }, function ($arguments, $haystack, $needle) { |
|
| 24 | + }, function($arguments, $haystack, $needle) { |
|
| 25 | 25 | return strpos($haystack, $needle) !== false; |
| 26 | 26 | }), |
| 27 | 27 | ]; |
@@ -10,18 +10,18 @@ |
||
| 10 | 10 | public function getFunctions() |
| 11 | 11 | { |
| 12 | 12 | return [ |
| 13 | - new ExpressionFunction('ceil', function ($num) { |
|
| 13 | + new ExpressionFunction('ceil', function($num) { |
|
| 14 | 14 | return sprintf('(is_numeric(%1$s) ? ceil(%1$s) : %1$s)', $num); |
| 15 | - }, function ($arguments, $num) { |
|
| 15 | + }, function($arguments, $num) { |
|
| 16 | 16 | if (!is_numeric($num)) { |
| 17 | 17 | return $num; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | return ceil($num); |
| 21 | 21 | }), |
| 22 | - new ExpressionFunction('floor', function ($num) { |
|
| 22 | + new ExpressionFunction('floor', function($num) { |
|
| 23 | 23 | return sprintf('(is_numeric(%1$s) ? floor(%1$s) : %1$s)', $num); |
| 24 | - }, function ($arguments, $num) { |
|
| 24 | + }, function($arguments, $num) { |
|
| 25 | 25 | if (!is_numeric($num)) { |
| 26 | 26 | return $num; |
| 27 | 27 | } |
@@ -30,10 +30,10 @@ |
||
| 30 | 30 | $i = 0; |
| 31 | 31 | foreach ($items as $item) { |
| 32 | 32 | if ($item->getUser()->getId() == $userId) { |
| 33 | - if (isset($items[$i-1]) && $items[$i-1]->getUser()->getId() == $userId) { |
|
| 34 | - $item->setMessage($items[$i-1]->getMessage().$item->getMessage()); |
|
| 35 | - $item->setReactionsCount(max($item->getReactionsCount(), $items[$i-1]->getReactionsCount())); |
|
| 36 | - unset($mergedItems[$i-1]); |
|
| 33 | + if (isset($items[$i - 1]) && $items[$i - 1]->getUser()->getId() == $userId) { |
|
| 34 | + $item->setMessage($items[$i - 1]->getMessage().$item->getMessage()); |
|
| 35 | + $item->setReactionsCount(max($item->getReactionsCount(), $items[$i - 1]->getReactionsCount())); |
|
| 36 | + unset($mergedItems[$i - 1]); |
|
| 37 | 37 | } |
| 38 | 38 | $mergedItems[$i] = $item; |
| 39 | 39 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | "Enter user access token from the Graph API Explorer\n". |
| 154 | 154 | "https://developers.facebook.com/tools/explorer\n"); |
| 155 | 155 | $auth = $this->auth; |
| 156 | - $question->setValidator(function ($token) use ($auth) { |
|
| 156 | + $question->setValidator(function($token) use ($auth) { |
|
| 157 | 157 | if (trim($token) == '') { |
| 158 | 158 | throw new \Exception('The token can not be empty'); |
| 159 | 159 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | private function generateGourceLog($topics, $comments, $replies) |
| 262 | 262 | { |
| 263 | - $count = ceil($topics->count()/10); |
|
| 263 | + $count = ceil($topics->count() / 10); |
|
| 264 | 264 | $msg = ''; |
| 265 | 265 | foreach ($topics as $topic) { |
| 266 | 266 | $topicTitle = ($topic->getMessage()) ? substr($topic->getMessage(), 0, 20) : $topic->getId(); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $msg .= $comment->getCreatedTime()->getTimeStamp().'|'.$comment->getUser()->getName().'|A|'.'/'.$count.'/'.$comment->getTopicId().'/'.$comment->getId().'/'.$commentMessage.".Comments\n"; |
| 281 | 281 | } |
| 282 | - foreach($replies as $reply) { |
|
| 282 | + foreach ($replies as $reply) { |
|
| 283 | 283 | $replyMessage = substr($reply->getMessage(), 0, 30); |
| 284 | 284 | $replyMessage = trim(preg_replace('/\s\s+/', ' ', $replyMessage)); |
| 285 | 285 | $replyMessage = sha1($replyMessage); |