Code Duplication    Length = 17-18 lines in 3 locations

src/Chamilo/CoreBundle/Entity/Session.php 2 locations

@@ 339-356 (lines=18) @@
336
     * @param SessionRelUser $subscription
337
     * @return bool
338
     */
339
    public function hasUser(SessionRelUser $subscription)
340
    {
341
        if ($this->getUsers()->count()) {
342
            $criteria = Criteria::create()->where(
343
                Criteria::expr()->eq("user", $subscription->getUser())
344
            )->andWhere(
345
                Criteria::expr()->eq("session", $subscription->getSession())
346
            )->andWhere(
347
                Criteria::expr()->eq("relationType", $subscription->getRelationType())
348
            );
349
350
            $relation = $this->getUsers()->matching($criteria);
351
352
            return $relation->count() > 0;
353
        }
354
355
        return false;
356
    }
357
358
    /**
359
     * @return ArrayCollection
@@ 930-946 (lines=17) @@
927
     * @param SessionRelCourseRelUser $subscription
928
     * @return bool
929
     */
930
    public function hasUserCourseSubscription(SessionRelCourseRelUser $subscription)
931
    {
932
        if ($this->getUserCourseSubscriptions()->count()) {
933
            $criteria = Criteria::create()->where(
934
                Criteria::expr()->eq("user", $subscription->getUser())
935
            )->andWhere(
936
                Criteria::expr()->eq("course", $subscription->getCourse())
937
            )->andWhere(
938
                Criteria::expr()->eq("session", $subscription->getSession())
939
            );
940
            $relation = $this->getUserCourseSubscriptions()->matching($criteria);
941
942
            return $relation->count() > 0;
943
        }
944
945
        return false;
946
    }
947
948
    /**
949
     * @return Course

src/Chamilo/CoreBundle/Entity/Course.php 1 location

@@ 439-456 (lines=18) @@
436
     * @param CourseRelUser $subscription
437
     * @return bool
438
     */
439
    private function hasSubscription(CourseRelUser $subscription)
440
    {
441
        if ($this->getUsers()->count()) {
442
            $criteria = Criteria::create()->where(
443
                Criteria::expr()->eq("user", $subscription->getUser())
444
            )->andWhere(
445
                Criteria::expr()->eq("status", $subscription->getStatus())
446
            )->andWhere(
447
                Criteria::expr()->eq("relationType", $subscription->getRelationType())
448
            );
449
450
            $relation = $this->getUsers()->matching($criteria);
451
452
            return $relation->count() > 0;
453
        }
454
455
        return false;
456
    }
457
458
    /**
459
     * @param User $user