ekinhbayar /
gitamp
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | namespace ekinhbayar\GitAmp\Event\GitHub; |
||
| 4 | |||
| 5 | use ekinhbayar\GitAmp\Event\BaseEvent; |
||
| 6 | use ekinhbayar\GitAmp\Presentation\Information; |
||
| 7 | use ekinhbayar\GitAmp\Presentation\Ring; |
||
| 8 | use ekinhbayar\GitAmp\Presentation\Sound\BaseSound; |
||
| 9 | use ekinhbayar\GitAmp\Presentation\Sound\Swell; |
||
| 10 | use ekinhbayar\GitAmp\Presentation\Sound\SwellEgg; |
||
| 11 | use ekinhbayar\GitAmp\Presentation\Type; |
||
| 12 | |||
| 13 | class ForkEvent extends BaseEvent |
||
| 14 | { |
||
| 15 | private const SPECIAL_REPOSITORIES = [ |
||
| 16 | 'ekinhbayar/gitamp', |
||
| 17 | 'amphp/amp', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | 2 | public function __construct(array $event) |
|
| 21 | { |
||
| 22 | 2 | parent::__construct( |
|
| 23 | 2 | (int) $event['id'], |
|
| 24 | 2 | new Type(5), |
|
| 25 | 2 | new Information($this->buildUrl($event), $this->buildPayload(), $this->buildMessage($event)), |
|
| 26 | 2 | new Ring(3000, 80), |
|
| 27 | 2 | $this->buildSound($event), |
|
| 28 | ); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 29 | } |
||
| 30 | |||
| 31 | 2 | private function buildUrl(array $event): string |
|
| 32 | { |
||
| 33 | 2 | return 'https://github.com/' . $event['repo']['name']; |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | private function buildPayload(): string |
|
| 37 | { |
||
| 38 | 2 | return 'not sure if stupid but works anyway'; |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | private function buildMessage(array $event): string |
|
| 42 | { |
||
| 43 | 2 | return \sprintf('%s forked %s', $event['actor']['login'], $event['repo']['name']); |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | private function buildSound(array $event): BaseSound |
|
| 47 | { |
||
| 48 | 2 | if (\in_array($event['repo']['name'], self::SPECIAL_REPOSITORIES, true)) { |
|
| 49 | 1 | return new SwellEgg(); |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | return new Swell(); |
|
| 53 | } |
||
| 54 | } |
||
| 55 |