Code Duplication    Length = 10-10 lines in 3 locations

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php 1 location

@@ 84-93 (lines=10) @@
81
     */
82
    abstract protected function getStageName() : string;
83
84
    private function convertExpression($expression)
85
    {
86
        if (is_array($expression)) {
87
            return array_map([$this, 'convertExpression'], $expression);
88
        } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
89
            return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
90
        }
91
92
        return Type::convertPHPToDatabaseValue(Expr::convertExpression($expression));
93
    }
94
95
    private function getDocumentPersister() : DocumentPersister
96
    {

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php 1 location

@@ 48-57 (lines=10) @@
45
        ];
46
    }
47
48
    private function convertExpression($expression)
49
    {
50
        if (is_array($expression)) {
51
            return array_map([$this, 'convertExpression'], $expression);
52
        } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
53
            return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
54
        }
55
56
        return Type::convertPHPToDatabaseValue(Expr::convertExpression($expression));
57
    }
58
59
    private function getDocumentPersister() : DocumentPersister
60
    {

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php 1 location

@@ 273-282 (lines=10) @@
270
        return $this;
271
    }
272
273
    private function convertExpression($expression)
274
    {
275
        if (is_array($expression)) {
276
            return array_map([$this, 'convertExpression'], $expression);
277
        } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
278
            return '$' . $this->getDocumentPersister($this->class)->prepareFieldName(substr($expression, 1));
279
        }
280
281
        return Type::convertPHPToDatabaseValue(Expr::convertExpression($expression));
282
    }
283
284
    private function convertTargetFieldName($fieldName)
285
    {