AsgardCms /
Notification
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Modules\Notification\Repositories\Cache; |
||
| 4 | |||
| 5 | use Modules\Core\Repositories\Cache\BaseCacheDecorator; |
||
| 6 | use Modules\Notification\Repositories\NotificationRepository; |
||
| 7 | |||
| 8 | class CacheNotificationDecorator extends BaseCacheDecorator implements NotificationRepository |
||
| 9 | { |
||
| 10 | public function __construct(NotificationRepository $notification) |
||
| 11 | { |
||
| 12 | parent::__construct(); |
||
| 13 | $this->entityName = 'notification.notifications'; |
||
| 14 | $this->repository = $notification; |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param int $userId |
||
| 19 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 20 | */ |
||
| 21 | View Code Duplication | public function latestForUser($userId) |
|
|
0 ignored issues
–
show
|
|||
| 22 | { |
||
| 23 | return $this->cache |
||
| 24 | ->tags([$this->entityName, 'global']) |
||
| 25 | ->remember( |
||
| 26 | "{$this->locale}.{$this->entityName}.latestForUser.{$userId}", |
||
| 27 | $this->cacheTime, |
||
| 28 | function () use ($userId) { |
||
| 29 | return $this->repository->latestForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method latestForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 30 | } |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Mark the given notification id as "read" |
||
| 36 | * @param int $notificationId |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | public function markNotificationAsRead($notificationId) |
||
| 40 | { |
||
| 41 | $this->cache->tags($this->entityName)->flush(); |
||
| 42 | |||
| 43 | return $this->repository->markNotificationAsRead($notificationId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method markNotificationAsRead() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get all the notifications for the given user id |
||
| 48 | * @param int $userId |
||
| 49 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 50 | */ |
||
| 51 | View Code Duplication | public function allForUser($userId) |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 52 | { |
||
| 53 | return $this->cache |
||
| 54 | ->tags([$this->entityName, 'global']) |
||
| 55 | ->remember( |
||
| 56 | "{$this->locale}.{$this->entityName}.allForUser.{$userId}", |
||
| 57 | $this->cacheTime, |
||
| 58 | function () use ($userId) { |
||
| 59 | return $this->repository->allForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method allForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 60 | } |
||
| 61 | ); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get all the read notifications for the given user id |
||
| 66 | * @param int $userId |
||
| 67 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 68 | */ |
||
| 69 | View Code Duplication | public function allReadForUser($userId) |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 70 | { |
||
| 71 | return $this->cache |
||
| 72 | ->tags([$this->entityName, 'global']) |
||
| 73 | ->remember( |
||
| 74 | "{$this->locale}.{$this->entityName}.allReadForUser.{$userId}", |
||
| 75 | $this->cacheTime, |
||
| 76 | function () use ($userId) { |
||
| 77 | return $this->repository->allReadForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method allReadForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 78 | } |
||
| 79 | ); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Get all the unread notifications for the given user id |
||
| 84 | * @param int $userId |
||
| 85 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 86 | */ |
||
| 87 | View Code Duplication | public function allUnreadForUser($userId) |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 88 | { |
||
| 89 | return $this->cache |
||
| 90 | ->tags([$this->entityName, 'global']) |
||
| 91 | ->remember( |
||
| 92 | "{$this->locale}.{$this->entityName}.allUnreadForUser.{$userId}", |
||
| 93 | $this->cacheTime, |
||
| 94 | function () use ($userId) { |
||
| 95 | return $this->repository->allUnreadForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method allUnreadForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 96 | } |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Delete all the notifications for the given user |
||
| 102 | * @param int $userId |
||
| 103 | * @return bool |
||
| 104 | */ |
||
| 105 | public function deleteAllForUser($userId) |
||
| 106 | { |
||
| 107 | $this->cache->tags($this->entityName)->flush(); |
||
| 108 | |||
| 109 | return $this->repository->deleteAllForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method deleteAllForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 110 | } |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Mark all the notifications for the given user as read |
||
| 114 | * @param int $userId |
||
| 115 | * @return bool |
||
| 116 | */ |
||
| 117 | public function markAllAsReadForUser($userId) |
||
| 118 | { |
||
| 119 | $this->cache->tags($this->entityName)->flush(); |
||
| 120 | |||
| 121 | return $this->repository->markAllAsReadForUser($userId); |
||
|
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
Modules\Core\Repositories\BaseRepository as the method markAllAsReadForUser() does only exist in the following implementations of said interface: Modules\Notification\Rep...heNotificationDecorator, Modules\Notification\Rep...tNotificationRepository.
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
| 122 | } |
||
| 123 | } |
||
| 124 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.