Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 1bbc9c3

Browse files
committed
:octocat: moved functions.php to /src
1 parent 78040a6 commit 1bbc9c3

File tree

4 files changed

+45
-43
lines changed

4 files changed

+45
-43
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"homepage": "https://github.com/chillerlan/php-oauth-providers",
55
"license": "MIT",
66
"type": "library",
7-
"minimum-stability": "stable",
87
"keywords": [
98
"oauth", "oauth2", "api", "client", "psr-7", "psr-17", "psr-18", "rfc5849", "rfc6749",
109
"amazon", "bigcartel", "deezer", "deviantart", "discogs", "discord", "flickr", "foursquare",
@@ -37,7 +36,10 @@
3736
"autoload": {
3837
"psr-4": {
3938
"chillerlan\\OAuth\\Providers\\": "src/"
40-
}
39+
},
40+
"files": [
41+
"src/functions.php"
42+
]
4143
},
4244
"autoload-dev": {
4345
"psr-4": {

examples/create-docblocks.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
$storage = null;
2929

3030
require_once __DIR__.'/provider-example-common.php';
31-
require_once __DIR__.'/functions.php';
3231

3332
$table = [
3433
' Provider | API keys | revoke access ',
3534
'----------|----------|---------------',
3635
];
3736

38-
foreach(getProviders() as $p){
37+
foreach(\chillerlan\OAuth\Providers\getProviders() as $p){
3938
[$name, $fqcn] = $p;
4039
/** @var \chillerlan\OAuth\Core\OAuthInterface $provider */
4140
$provider = new $fqcn($http, $storage, $options, $logger);

examples/functions.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/functions.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* @filesource functions.php
4+
* @created 31.07.2019
5+
* @author smiley <smiley@chillerlan.net>
6+
* @copyright 2019 smiley
7+
* @license MIT
8+
*/
9+
10+
namespace chillerlan\OAuth\Providers;
11+
12+
use chillerlan\OAuth\Core\OAuthInterface;
13+
use FilesystemIterator, RecursiveDirectoryIterator, RecursiveIteratorIterator, ReflectionClass;
14+
15+
if(!\function_exists(__NAMESPACE__.'\\getProviders')){
16+
17+
function getProviders():array{
18+
$providers = [];
19+
20+
/** @var \SplFileInfo $e */
21+
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)) as $e){
22+
23+
if($e->getExtension() !== 'php' || \realpath($e->getPath()) === __DIR__){
24+
continue;
25+
}
26+
27+
$class = __NAMESPACE__.\str_replace('/', '\\', \substr($e->getPathname(), \strlen(__DIR__), -4));
28+
$r = new ReflectionClass($class);
29+
30+
if(!$r->implementsInterface(OAuthInterface::class) || $r->isAbstract()){
31+
continue;
32+
}
33+
34+
$providers[\hash('crc32b', $r->getShortName())] = [$r->getShortName(), $class];
35+
}
36+
37+
return $providers;
38+
}
39+
40+
}

0 commit comments

Comments
 (0)