Code Duplication    Length = 16-17 lines in 2 locations

src/Infrastructure/Model/Repository/EloquentMongoDB/EloquentReadRepository.php 2 locations

@@ 38-53 (lines=16) @@
35
     *
36
     * @return array
37
     */
38
    public function findBy(Filter $filter = null, Sort $sort = null, Fields $fields = null)
39
    {
40
        $model = self::$instance;
41
        $query = $model->query();
42
        $columns = ($fields) ? $fields->get() : ['*'];
43
44
        if ($filter) {
45
            EloquentFilter::filter($query, $filter);
46
        }
47
48
        if ($sort) {
49
            EloquentSorter::sort($query, $sort);
50
        }
51
52
        return $query->get($columns)->toArray();
53
    }
54
55
    /**
56
     * Returns all instances of the type meeting $distinctFields values.
@@ 64-80 (lines=17) @@
61
     *
62
     * @return array
63
     */
64
    public function findByDistinct(Fields $distinctFields, Filter $filter = null, Sort $sort = null)
65
    {
66
        $model = self::$instance;
67
        $query = $model->query();
68
69
        $columns = (count($fields = $distinctFields->get()) > 0) ? $fields : ['*'];
70
71
        if ($filter) {
72
            EloquentFilter::filter($query, $filter);
73
        }
74
75
        if ($sort) {
76
            EloquentSorter::sort($query, $sort);
77
        }
78
79
        return $query->getQuery()->distinct()->get($columns);
80
    }
81
82
    /**
83
     * Returns the total amount of elements in the repository given the restrictions provided by the Filter object.