Code Duplication    Length = 15-20 lines in 2 locations

src/Promise/Visitor/AddMagicGetMethod.php 1 location

@@ 65-79 (lines=15) @@
62
    /**
63
     * @return Node\Stmt\If_
64
     */
65
    private function buildGetExpression(): Node\Stmt\If_
66
    {
67
        $resolved = resolveMethodCall('this', $this->resolverProperty, $this->resolveMethod);
68
        $stmt = new Node\Stmt\Return_(new Node\Expr\PropertyFetch($resolved, '{$name}'));
69
70
        return throwExceptionOnNull(
71
            $resolved,
72
            $stmt,
73
            'Property `%s` not loaded in `__get()` method for `%s`',
74
            [
75
                new Node\Arg(new Node\Expr\Variable('name')),
76
                $this->class
77
            ]
78
        );
79
    }
80
}
81

src/Promise/Visitor/AddMagicSetMethod.php 1 location

@@ 65-84 (lines=20) @@
62
    /**
63
     * @return Node\Stmt\If_
64
     */
65
    private function buildSetExpression(): Node\Stmt\If_
66
    {
67
        $resolved = resolveMethodCall('this', $this->resolverProperty, $this->resolveMethod);
68
        $stmt = new Node\Stmt\Expression(
69
            new Node\Expr\Assign(
70
                new Node\Expr\PropertyFetch($resolved, '{$name}'),
71
                new Node\Expr\Variable('value')
72
            )
73
        );
74
75
        return throwExceptionOnNull(
76
            $resolved,
77
            $stmt,
78
            'Property `%s` not loaded in `__set()` method for `%s`',
79
            [
80
                new Node\Arg(new Node\Expr\Variable('name')),
81
                $this->class
82
            ]
83
        );
84
    }
85
}
86