Conditions | 12 |
Paths | 1 |
Total Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
35 | public function createPath(): Objects\Path |
||
36 | { |
||
37 | return new Objects\Path( |
||
38 | $this->getSummary(), |
||
39 | $this->getReference() ? $this->getReference()->createReference() : null, |
||
40 | $this->getDescription(), |
||
41 | $this->getOperation(Objects\Path::METHOD_GET) |
||
42 | ? $this->getOperation(Objects\Path::METHOD_GET)->createOperation() |
||
43 | : null, |
||
44 | $this->getOperation(Objects\Path::METHOD_PUT) |
||
45 | ? $this->getOperation(Objects\Path::METHOD_PUT)->createOperation() |
||
46 | : null, |
||
47 | $this->getOperation(Objects\Path::METHOD_POST) |
||
48 | ? $this->getOperation(Objects\Path::METHOD_POST)->createOperation() |
||
49 | : null, |
||
50 | $this->getOperation(Objects\Path::METHOD_DELETE) |
||
51 | ? $this->getOperation(Objects\Path::METHOD_DELETE)->createOperation() |
||
52 | : null, |
||
53 | $this->getOperation(Objects\Path::METHOD_PATCH) |
||
54 | ? $this->getOperation(Objects\Path::METHOD_PATCH)->createOperation() |
||
55 | : null, |
||
56 | $this->getOperation(Objects\Path::METHOD_OPTIONS) |
||
57 | ? $this->getOperation(Objects\Path::METHOD_OPTIONS)->createOperation() |
||
58 | : null, |
||
59 | $this->getOperation(Objects\Path::METHOD_HEAD) |
||
60 | ? $this->getOperation(Objects\Path::METHOD_HEAD)->createOperation() |
||
61 | : null, |
||
62 | $this->getOperation(Objects\Path::METHOD_TRACE) |
||
63 | ? $this->getOperation(Objects\Path::METHOD_TRACE)->createOperation() |
||
64 | : null, |
||
65 | $this->getServers() ? $this->getServers()->createServerCollection() : null, |
||
66 | $this->getParameters() ? $this->getParameters()->createParameterCollection() : null, |
||
67 | $this->getExtensions() |
||
68 | ); |
||
69 | } |
||
70 | |||
149 |