Improved style

This commit is contained in:
Marcin Kurczewski 2014-11-11 14:27:36 +01:00
parent 584d06a7f1
commit 2f12ec0a5e
4 changed files with 23 additions and 13 deletions

View file

@ -167,17 +167,18 @@ abstract class AbstractSearchParser
protected function matches($text, $array)
{
$transform = function($text)
{
return str_replace('_', '', strtolower($text));
};
$text = $transform($text);
$text = $this->transformText($text);
foreach ($array as $elem)
{
if ($transform($elem) == $text)
if ($this->transformText($elem) === $text)
return true;
}
return false;
}
protected function transformText($text)
{
return str_replace('_', '', strtolower($text));
}
}

View file

@ -32,7 +32,7 @@ class NetworkingService
$this->httpHelper->setHeader('Pragma', 'public');
$this->httpHelper->setHeader('Cache-Control', 'public, max-age=' . $secondsToLive);
$this->httpHelper->setHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + $secondsToLive));
$this->httpHelper->setHeader( 'Content-Type', MimeHelper::getMimeTypeFromFile($fullPath));
$this->httpHelper->setHeader('Content-Type', MimeHelper::getMimeTypeFromFile($fullPath));
if ($customFileName)
$this->httpHelper->setHeader('Content-Disposition', 'inline; filename="' . $customFileName . '"');

View file

@ -106,7 +106,11 @@ class PostSnapshotProvider implements ISnapshotProvider
sort($data['tags']);
sort($data['relations']);
usort($data['notes'], function ($note1, $note2) { return $note1['x'] - $note2['x']; });
usort($data['notes'],
function ($note1, $note2)
{
return $note1['x'] - $note2['x'];
});
return $data;
}

View file

@ -194,10 +194,15 @@ class TagService
foreach ($posts as $post)
{
$newTags = $post->getTags();
$newTags = array_filter($newTags, function(Tag $tag) use ($sourceTag) {
return $tag->getId() !== $sourceTag->getId();
});
$newTags []= $targetTag;
$newTags[] = $targetTag;
$newTags = array_filter(
$newTags,
function(Tag $tag) use ($sourceTag)
{
return $tag->getId() !== $sourceTag->getId();
});
$post->setTags($newTags);
$this->postDao->save($post);
$this->postHistoryService->savePostChange($post);