summaryrefslogtreecommitdiffstats
path: root/lib/private/comments
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-12-03 17:16:51 +0100
committerArthur Schiwon <blizzz@owncloud.com>2015-12-09 14:34:23 +0100
commit9dc417183077752080799db8d5962ba5147fed29 (patch)
tree757e0bddb5d1b18226e4cda2b07c5de9a8240f42 /lib/private/comments
parent4273689e9f37adadef2d514714fadcc38582b87c (diff)
downloadnextcloud-server-9dc417183077752080799db8d5962ba5147fed29.tar.gz
nextcloud-server-9dc417183077752080799db8d5962ba5147fed29.zip
parameter checks for setting actor and object to happen only in one place
Diffstat (limited to 'lib/private/comments')
-rw-r--r--lib/private/comments/comment.php10
-rw-r--r--lib/private/comments/manager.php11
2 files changed, 8 insertions, 13 deletions
diff --git a/lib/private/comments/comment.php b/lib/private/comments/comment.php
index 2e9e4bd3d84..8efd7d5613a 100644
--- a/lib/private/comments/comment.php
+++ b/lib/private/comments/comment.php
@@ -229,7 +229,10 @@ class Comment implements IComment {
* @since 9.0.0
*/
public function setActor($actorType, $actorId) {
- if(!is_string($actorType) || !is_string($actorId)) {
+ if(
+ !is_string($actorType) || empty($actorType)
+ || !is_string($actorId) || empty($actorId)
+ ) {
throw new \InvalidArgumentException('String expected.');
}
$this->data['actorType'] = $actorType;
@@ -312,7 +315,10 @@ class Comment implements IComment {
* @since 9.0.0
*/
public function setObject($objectType, $objectId) {
- if(!is_string($objectType) || !is_string($objectId)) {
+ if(
+ !is_string($objectType) || empty($objectType)
+ || !is_string($objectId) || empty($objectId)
+ ) {
throw new \InvalidArgumentException('String expected.');
}
$this->data['objectType'] = $objectType;
diff --git a/lib/private/comments/manager.php b/lib/private/comments/manager.php
index 12b90a063d1..184e37eb12a 100644
--- a/lib/private/comments/manager.php
+++ b/lib/private/comments/manager.php
@@ -354,20 +354,9 @@ class Manager implements ICommentsManager {
* @param string $objectType the object type the comment is attached to
* @param string $objectId the object id the comment is attached to
* @return IComment
- * @throws \InvalidArgumentException
* @since 9.0.0
*/
public function create($actorType, $actorId, $objectType, $objectId) {
- if(
- !is_string($actorType) || empty($actorType)
- || !is_string($actorId) || empty($actorId)
- || !is_string($objectType) || empty($objectType)
- || !is_string($objectId) || empty($objectId)
- ) {
- // unsure whether it's a good place to enforce it here, since the
- // comment instance can be manipulated anyway.
- throw new \InvalidArgumentException('All arguments must be non-empty strings');
- }
$comment = new Comment();
$comment
->setActor($actorType, $actorId)