for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Dtc\QueueBundle\ODM;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\MongoDB\DocumentManager;
trait CommonTrait
{
/**
* @param string $objectName
* @param string $field
* @param \DateTime $olderThan
*
* @return int
*/
protected function removeOlderThan($objectName, $field, \DateTime $olderThan)
/** @var DocumentManager $objectManager */
$objectManager = $this->getObjectManager();
$qb = $objectManager->createQueryBuilder($objectName);
$qb
->remove()
->field($field)->lt($olderThan);
$query = $qb->getQuery();
$result = $query->execute();
if (isset($result['n'])) {
return $result['n'];
}
return 0;
* @return ObjectManager
abstract public function getObjectManager();
public function stopIdGenerator($objectName)
$objectName
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
// Not needed for ODM
public function restoreIdGenerator($objectName)
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.