| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 5 | public function addAttachment(string $path, string $workItemId, string $projectId): Attachment |
|
| 22 | { |
||
| 23 | // First, upload the file... |
||
| 24 | 5 | $response = $this->post( |
|
|
|
|||
| 25 | 5 | "{$projectId}/_apis/wit/attachments", |
|
| 26 | [ |
||
| 27 | 5 | 'headers' => ['Content-Type' => 'application/octet-stream'], |
|
| 28 | 5 | 'query' => ['fileName' => basename($path), 'api-version' => $this->apiVersion], |
|
| 29 | 5 | 'body' => fopen($path, 'r'), |
|
| 30 | ] |
||
| 31 | ); |
||
| 32 | |||
| 33 | // ...then, attach it to the work item |
||
| 34 | 1 | $this->patch( |
|
| 35 | 1 | "{$projectId}/_apis/wit/workitems/{$workItemId}", |
|
| 36 | [ |
||
| 37 | 1 | 'headers' => ['Content-Type' => 'application/json-patch+json'], |
|
| 38 | 1 | 'json' => $this->toDevOpsAttachment($response['url']), |
|
| 39 | ] |
||
| 40 | ); |
||
| 41 | |||
| 42 | 1 | return $this->fromDevOpsAttachment($response); |
|
| 43 | } |
||
| 44 | } |
||
| 45 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.