This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy the latest hash to the clipboard | |
latest = log --pretty=format:'%H' -n1 | |
h = !git latest && git latest | pbcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testAuthorHasPostsArray() | |
{ | |
self::assertIsArray( | |
(new Author())->getPosts(), | |
'Author should have an accessible array of posts' | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testAuthorHasPostsArray() | |
{ | |
$author = new Author(); | |
self::assertIsArray($author->getPosts()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post | |
{ | |
protected $sidebarTypes = [8, 11]; | |
protected $authorEditTimeout = 2592000; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -7,8 +7,14 @@ class Post | |
$isAuthor = $this->getAuthorId() == $user->getId(); | |
+ $isSupervisor = $this->getRole() == 4; | |
+ $isSidebarPost = $this->getType() == 8; | |
$isTooOld = $this->created_at < time() — 2592000; | |
+ if ($isSupervisor && $isSidebarPost) { | |
+ return true; | |
+ } | |
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post | |
{ | |
public function canEdit(User $user) : bool | |
{ | |
$isEditor = $user->getRole() == 3 && $this->getEditorId() == $user->getId(); | |
$isAdmin = $user->getRole() > 5; | |
$isAuthor = $this->getAuthorId() == $user->getId(); | |
$isSupervisor = $this->getRole() == 4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post | |
{ | |
public function canEdit(User $user) : bool | |
{ | |
$isEditor = $user->getRole() == 3 && $this->getEditorId() == $user->getId(); | |
$isAdmin = $user->getRole() > 5; | |
$isAuthor = $this->getAuthorId() == $user->getId(); | |
$isTooOld = $this->created_at < time() — 2592000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post | |
{ | |
public function canEdit(User $user) : bool | |
{ | |
$canEdit = false; | |
if (($user->getRole() == 3 && $this->getEditorId() == $user->getId()) || $user->getRole() > 5 || ($this->getAuthorId() == $user->getId() && $this->created_at < time() — 2592000)) { | |
$canEdit = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function calculateSalePrice($item, $discount = 0) { | |
if ($discount > 0) { | |
return calculateDiscountedPrice($item->getPrice, $discount); | |
} | |
return $item->getPrice(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function calculateSalePrice($item, $discount = 0) { | |
if ($discount == 0) { | |
return $item->getPrice(); | |
} | |
return calculateDiscountedPrice($item->getPrice, $discount); | |
} |
NewerOlder