Developmint /
netlify-build-hook
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Developmint\NetlifyBuildHook; |
||
| 4 | |||
| 5 | use GuzzleHttp\Client; |
||
| 6 | |||
| 7 | class NetlifyBuildHook |
||
| 8 | { |
||
| 9 | /** @var \GuzzleHttp\Client */ |
||
| 10 | protected $client; |
||
| 11 | protected $id; |
||
| 12 | protected $branch; |
||
| 13 | protected $title; |
||
| 14 | const BASE_URL = 'https://api.netlify.com/build_hooks/'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param \GuzzleHttp\Client $client HTTP Client that'll trigger the hook |
||
| 18 | * @param string $id string Hook identifier |
||
| 19 | * @param string? $branch The branch that should be used for the build |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 20 | * @param string? $title The title for the deploy message on Netlify |
||
| 21 | */ |
||
| 22 | public function __construct(Client $client, string $id, $title = null, $branch = null) |
||
| 23 | { |
||
| 24 | $this->client = $client; |
||
| 25 | $this->id = $id; |
||
| 26 | $this->title = $title; |
||
| 27 | $this->branch = $branch; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function trigger() : void |
||
| 31 | { |
||
| 32 | $this->client->post(self::BASE_URL . $this->id, [ |
||
| 33 | "query" => [ |
||
| 34 | 'trigger_branch' => $this->branch, |
||
| 35 | 'trigger_title' => $this->title |
||
| 36 | ] |
||
| 37 | ]); |
||
| 38 | } |
||
| 39 | } |