Code Duplication    Length = 39-39 lines in 2 locations

src/Builder/ClassBuilder.php 1 location

@@ 93-131 (lines=39) @@
90
91
        $this->addH2('Methods');
92
        /* Render methods of a class */
93
        foreach ($class->getMethods() as $method) {
94
            $docBlock = $method->getDocBlock();
95
            $params = [];
96
            if($docBlock !== null) {
97
                /** @var Param $param */
98
                foreach ($docBlock->getTagsByName('param') as $param) {
99
                    $params[$param->getVariableName()] = $param;
100
                }
101
            }
102
            $args = '';
103
            /** @var Argument $argument */
104
            foreach ($method->getArguments() as $argument) {
105
                // TODO: defaults, types
106
                $args .=  ' $' . $argument->getName() . ', ';
107
            }
108
            $args = substr($args, 0, -2);
109
110
            $modifiers = $method->getVisibility();
111
            $modifiers .= $method->isAbstract() ? ' abstract' : '';
112
            $modifiers .= $method->isFinal() ? ' final' : '';
113
            $modifiers .= $method->isStatic() ? ' static' : '';
114
            $this->addLine('.. rst-class:: ' . $modifiers)->addLine();
115
            $this->indent();
116
            $this->beginPhpDomain('method', $method->getName().'('.$args.')');
117
            if ($docBlock)
118
                $this->addMultiline($docBlock->getDescription());
119
            $this->addLine();
120
            if (!empty($params)) {
121
                foreach ($method->getArguments() as $argument) {
122
                    /** @var Param $param */
123
                    $param = $params[$argument->getName()];
124
                    if ($param !== null)
125
                        $this->addMultiline(':param ' . $param->getType() . ' $' . $argument->getName() . ': ' . $param->getDescription(), true);
126
                }
127
            }
128
            $this->endPhpDomain('method');
129
            $this->unindent();
130
131
        }
132
        $this->endPhpDomain(); //class
133
    }
134

src/Builder/TraitBuilder.php 1 location

@@ 72-110 (lines=39) @@
69
70
        $this->addH2('Methods');
71
        /* Render methods of a trait */
72
        foreach ($trait->getMethods() as $method) {
73
            $docBlock = $method->getDocBlock();
74
            $params = [];
75
            if($docBlock !== null) {
76
                /** @var Param $param */
77
                foreach ($docBlock->getTagsByName('param') as $param) {
78
                    $params[$param->getVariableName()] = $param;
79
                }
80
            }
81
            $args = '';
82
            /** @var Argument $argument */
83
            foreach ($method->getArguments() as $argument) {
84
                // TODO: defaults, types
85
                $args .=  ' $' . $argument->getName() . ', ';
86
            }
87
            $args = substr($args, 0, -2);
88
89
            $modifiers = $method->getVisibility();
90
            $modifiers .= $method->isAbstract() ? ' abstract' : '';
91
            $modifiers .= $method->isFinal() ? ' final' : '';
92
            $modifiers .= $method->isStatic() ? ' static' : '';
93
            $this->addLine('.. rst-class:: ' . $modifiers)->addLine();
94
            $this->indent();
95
            $this->beginPhpDomain('method', $method->getName().'('.$args.')');
96
            if ($docBlock)
97
                $this->addMultiline($docBlock->getDescription());
98
            $this->addLine();
99
            if (!empty($params)) {
100
                foreach ($method->getArguments() as $argument) {
101
                    /** @var Param $param */
102
                    $param = $params[$argument->getName()];
103
                    if ($param !== null)
104
                        $this->addMultiline(':param ' . $param->getType() . ' $' . $argument->getName() . ': ' . $param->getDescription(), true);
105
                }
106
            }
107
            $this->endPhpDomain('method');
108
            $this->unindent();
109
110
        }
111
        $this->endPhpDomain(); //trait
112
    }
113