| 1 | <?php |
||
| 7 | abstract class AbstractOrigin implements OriginInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The name of the origin. |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | public $name; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The Request object associated with this webhook. |
||
| 18 | * |
||
| 19 | * @var Illuminate\Http\Request |
||
| 20 | */ |
||
| 21 | public $request; |
||
| 22 | |||
| 23 | 36 | public function __construct(Request $request) |
|
|
1 ignored issue
–
show
|
|||
| 24 | { |
||
| 25 | 36 | $this->request = $request; |
|
|
1 ignored issue
–
show
|
|||
| 26 | 36 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * Determines whether or not the Request originated from the webhook origin. |
||
| 30 | * |
||
| 31 | * @param Illuminate\Http\Request $request The Request object |
||
| 32 | * |
||
| 33 | * @return bool Returns true if the request originated from this origin. False otherwise. |
||
| 34 | */ |
||
| 35 | abstract public function originated(); |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Verifies the authenticity of a webhook request from the origin. |
||
| 39 | * |
||
| 40 | * @param Illuminate\Http\Request $request The Request object |
||
| 41 | * |
||
| 42 | * @return bool Returns true if the request is authentic. False otherwise. |
||
| 43 | */ |
||
| 44 | abstract public function verify(); |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Gets the event the triggered the webhook request. |
||
| 48 | * |
||
| 49 | * @param Illuminate\Http\Request $request The Request object |
||
| 50 | * |
||
| 51 | * @return string The name of the event, e.g. push, release, create, etc. |
||
| 52 | */ |
||
| 53 | abstract public function event(); |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Gets the URL to be cloned from. |
||
| 57 | * |
||
| 58 | * @param Illuminate\Http\Request $request The Request object |
||
| 59 | * |
||
| 60 | * @return string The URL of the repo. |
||
| 61 | */ |
||
| 62 | abstract public function getRepoUrl(); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Gets the ID of the commit that is to be cloned. |
||
| 66 | * |
||
| 67 | * @param Illuminate\Http\Request $request The Request object |
||
| 68 | * |
||
| 69 | * @return string The commit ID. |
||
| 70 | */ |
||
| 71 | abstract public function getCommitId(); |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Determines if a target IP address is within a particular IP address range. |
||
| 75 | * |
||
| 76 | * @param string $target_ip The IP address to check |
||
| 77 | * @param string $range_ip The IP address defining the range |
||
| 78 | * @param int $cidr_mask The CIDR notation net mask defining the range |
||
| 79 | * |
||
| 80 | * @return bool True if the target IP falls within the specified range. Otherwise false. |
||
| 81 | */ |
||
| 82 | 18 | protected function ipInRange($target_ip, $range_ip, $cidr_mask) |
|
| 89 | } |
||
| 90 |