Skip to content

Commit e12c1ff

Browse files
Supabase client for php: v3.0.0
1 parent ab60b9f commit e12c1ff

7 files changed

Lines changed: 126 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@
5656
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
5757
],
5858
"test:unit": "phpunit",
59-
"test:type": "phpstan analyse --ansi",
59+
"test:type": "phpstan analyse --ansi --no-progress",
6060
"test": [
61-
"@test:unit",
6261
"@test:type"
6362
]
6463
},

index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
require __dir__.'/vendor/autoload.php';
4+
use Supabase\Client;
5+
6+
$client = Client::connect();
7+
$client->setURL('https://supabase.co');
8+
$client->setApiKey('fsvbg');

phpstan.neon.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
6+
reportUnmatchedIgnoredErrors: true
7+

phpunit.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
requireCoverageMetadata="true"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
failOnPhpunitDeprecation="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
colors="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
22+
<include>
23+
<directory>src</directory>
24+
</include>
25+
</source>
26+
</phpunit>

src/Client.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Supabase;
4+
5+
class Client extends Supabase
6+
{
7+
/*
8+
/**
9+
* @var object Supabase
10+
*/
11+
// protected object $supabase;
12+
13+
/*
14+
* @var string Supabase URL
15+
*/
16+
// protected string $url;
17+
18+
/*
19+
* @var string Supabase API KEY
20+
*/
21+
// protected string $apiKey;
22+
23+
public function __construct()
24+
{
25+
// $this->supabase = new Supabase($this->url, $this->apiKey);
26+
}
27+
/*
28+
public function setURL(string $url): string
29+
{
30+
return $this->url = $url;
31+
}
32+
33+
public function setApiKey(string $key): string
34+
{
35+
return $this->apiKey = $key;
36+
}
37+
*/
38+
}

src/Supabase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Supabase;
4+
5+
class Supabase
6+
{
7+
/* public function __construct(string $url, string $key)
8+
{
9+
//
10+
}
11+
*/
12+
}

tests/SupabaseClientTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Tests;
4+
5+
use PHPUnit\Framework\Attributes\CoversClass;
6+
use PHPUnit\Framework\Attributes\Test;
7+
use PHPUnit\Framework\TestCase;
8+
use InvalidArgumentException;
9+
use Supabase\Client;
10+
11+
#[CoversClass(Client::class)]
12+
class SupabaseClientTest extends TestCase
13+
{
14+
/**
15+
* @var object supabase client
16+
*/
17+
private Client $client;
18+
19+
#[Test]
20+
protected function setUp(): void
21+
{
22+
$this->client = new Client();
23+
$this->assertInstanceOf(Client::class, $this->client);
24+
$this->assertSame(Client::class, get_class($this->client));
25+
26+
}
27+
28+
/*
29+
#[Test]
30+
public function connect()
31+
{
32+
$this->assertSame('supabase', $this->client);
33+
} */
34+
}

0 commit comments

Comments
 (0)