lib/private/Comments/Manager.php
File Manager.php
has 474 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
Manager
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Manager implements ICommentsManager {
use EventEmitterTrait;
/** @var IDBConnection */
protected $dbConn;
Method delete
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function delete($id) {
return $this->emittingCall(function () use (&$id) {
if (!\is_string($id)) {
throw new \InvalidArgumentException('Parameter must be string');
}
Method update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function update(IComment $comment) {
return $this->emittingCall(function () use (&$comment) {
$qb = $this->dbConn->getQueryBuilder();
$affectedRows = $qb
->update('comments')
Method insert
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function insert(IComment &$comment) {
$qb = $this->dbConn->getQueryBuilder();
$affectedRows = $qb
->insert('comments')
->values([
Method getForObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getForObject(
$objectType,
$objectId,
$limit = 0,
$offset = 0,
Method setReadMark
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) {
$this->checkRoleParameters('Object', $objectType, $objectId);
$qb = $this->dbConn->getQueryBuilder();
$values = [
Method getTree
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getTree($id, $limit = 0, $offset = 0) {
$tree = [];
$tree['comment'] = $this->get($id);
$tree['replies'] = [];
Method getNumberOfUnreadCommentsForNodes
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getNumberOfUnreadCommentsForNodes($objectType, $objectIds, IUser $user) {
$qbMain = $this->dbConn->getQueryBuilder();
$qbSup = $this->dbConn->getQueryBuilder();
$unreadCountsForNodes = [];
Method getForObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
$objectType,
$objectId,
$limit = 0,
$offset = 0,
\DateTime $notOlderThan = null
Function prepareCommentForDatabaseWrite
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function prepareCommentForDatabaseWrite(IComment $comment) {
if (!$comment->getActorType()
|| !$comment->getActorId()
|| !$comment->getObjectType()
|| !$comment->getObjectId()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"