-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from SergkeiM/feature/add-laravel-support
Added laravel support
- Loading branch information
Showing
18 changed files
with
571 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Laravel Cloudflare. | ||
*/ | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Connection Name | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which of the connections below you wish to use as | ||
| your default connection for all work. Of course, you may use many | ||
| connections at once using the manager class. | ||
| | ||
*/ | ||
|
||
'default' => 'main', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Cloudflare Connections | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here are each of the connections setup for your application. Example | ||
| configuration has been included, but you may add as many connections as | ||
| you would like. | ||
| | ||
*/ | ||
|
||
'connections' => [ | ||
|
||
'main' => [ | ||
'token' => 'your-token', | ||
], | ||
|
||
'secondary' => [ | ||
'token' => 'your-token', | ||
], | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuites> | ||
<testsuite name="php-cloudflare-api Test Suite"> | ||
<directory>./test/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<groups> | ||
<exclude> | ||
<group>integration</group> | ||
</exclude> | ||
</groups> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<listeners> | ||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/> | ||
</listeners> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> | ||
<testsuites> | ||
<testsuite name="php-cloudflare-api Test Suite"> | ||
<directory>./test/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<groups> | ||
<exclude> | ||
<group>integration</group> | ||
</exclude> | ||
</groups> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src/</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Cloudflare; | ||
|
||
use Illuminate\Support\Arr; | ||
use InvalidArgumentException; | ||
|
||
class CloudflareFactory | ||
{ | ||
/** | ||
* Make a new github client. | ||
* | ||
* @param string[] $config | ||
* | ||
* @throws \InvalidArgumentException | ||
* | ||
* @return \Cloudflare\Client | ||
*/ | ||
public function make(array $config): Client | ||
{ | ||
$client = new Client(Arr::get($config, 'token')); | ||
|
||
return $client; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Cloudflare; | ||
|
||
use GrahamCampbell\Manager\AbstractManager; | ||
use Illuminate\Contracts\Config\Repository; | ||
|
||
/** | ||
* This is the cloudflare manager class. | ||
* | ||
* @method \Cloudflare\Client connection(string|null $name = null) | ||
* @method \Cloudflare\Client reconnect(string|null $name = null) | ||
* @method void disconnect(string|null $name = null) | ||
* @method array<string,\Cloudflare\Client> getConnections() | ||
* @method \Cloudflare\Endpoints\Accounts accounts() | ||
* @method \Cloudflare\Endpoints\D1 d1() | ||
* @method \Cloudflare\Endpoints\IP ips() | ||
* @method \Cloudflare\Endpoints\Zones zones() | ||
* @method \Cloudflare\Endpoints\Workers workers() | ||
* @method \Cloudflare\Endpoints\Tunnel tunnel() | ||
*/ | ||
class CloudflareManager extends AbstractManager | ||
{ | ||
/** | ||
* The factory instance. | ||
* | ||
* @var \Cloudflare\CloudflareFactory | ||
*/ | ||
protected CloudflareFactory $factory; | ||
|
||
/** | ||
* Create a new github manager instance. | ||
* | ||
* @param \Illuminate\Contracts\Config\Repository $config | ||
* @param \Cloudflare\CloudflareFactory $factory | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Repository $config, CloudflareFactory $factory) | ||
{ | ||
parent::__construct($config); | ||
$this->factory = $factory; | ||
} | ||
|
||
/** | ||
* Create the connection instance. | ||
* | ||
* @param array $config | ||
* | ||
* @return \Cloudflare\Client | ||
*/ | ||
protected function createConnection(array $config): Client | ||
{ | ||
return $this->factory->make($config); | ||
} | ||
|
||
/** | ||
* Get the configuration name. | ||
* | ||
* @return string | ||
*/ | ||
protected function getConfigName(): string | ||
{ | ||
return 'cloudflare'; | ||
} | ||
|
||
/** | ||
* Get the configuration for a connection. | ||
* | ||
* @param string|null $name | ||
* | ||
* @throws \InvalidArgumentException | ||
* | ||
* @return array | ||
*/ | ||
public function getConnectionConfig(string $name = null): array | ||
{ | ||
$config = parent::getConnectionConfig($name); | ||
|
||
return $config; | ||
} | ||
|
||
/** | ||
* Get the factory instance. | ||
* | ||
* @return \Cloudflare\CloudflareFactory | ||
*/ | ||
public function getFactory(): CloudflareFactory | ||
{ | ||
return $this->factory; | ||
} | ||
} |
Oops, something went wrong.