* @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;
* @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;
* @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)