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/GraphLookup.php 1 location

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

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
    {