Completed
Pull Request — master (#68)
by Cristiano
05:36
created

PhpMethod   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 9
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10
1
<?php declare(strict_types=1);
2
/*
3
 * Copyright 2011 Johannes M. Schmitt <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace gossi\codegen\model;
19
20
use gossi\codegen\model\parts\AbstractPart;
21
use gossi\codegen\model\parts\BodyPart;
22
use gossi\codegen\model\parts\FinalPart;
23
use gossi\codegen\model\parts\ParametersPart;
24
use gossi\codegen\model\parts\ReferenceReturnPart;
25
use gossi\codegen\model\parts\TypeDocblockGeneratorPart;
26
use gossi\docblock\tags\ReturnTag;
27
28
/**
29
 * Represents a PHP method.
30
 *
31
 * @author Johannes M. Schmitt <[email protected]>
32
 * @author Thomas Gossmann
33
 */
34
class PhpMethod extends AbstractPhpMember implements RoutineInterface, GenerateableInterface {
35
	use AbstractPart;
36
	use BodyPart;
37
	use FinalPart;
38
	use ParametersPart;
39
	use ReferenceReturnPart;
40
	use TypeDocblockGeneratorPart;
41
42
	/**
43
	 * Creates a new PHP method.
44
	 *
45
	 * @param string $name the method name
46
	 */
47
	public static function create(string $name): static {
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STATIC
Loading history...
48
		return new static($name);
49 20
	}
50 20
51
	public function __construct(string $name) {
52
		parent::__construct($name);
53 34
		$this->initParameters();
54 34
	}
55 34
56 34
	/**
57
	 * Generates docblock based on provided information
58
	 */
59
	public function generateDocblock(): void {
60
		$docblock = $this->getDocblock();
61 9
		$docblock->setShortDescription($this->getDescription());
62 9
		$docblock->setLongDescription($this->getLongDescription());
63 9
64 9
		// return tag
65
		$this->generateTypeTag(new ReturnTag());
66
67 9
		// param tags
68
		$this->generateParamDocblock();
69
	}
70
}
71