Commit 8 of 11:
6db1c8e3d9
use singleton
previous
next
whole branch
Review threads live on the whole diff, not on one commit, so
none are shown here - a thread's line means something in the
branch's final form, and painting it into an intermediate
step would put it on code it is not about.
Changes to .env.example @@ -0,0 +1,1 @@ 1 + PUBLISHABLE_API_KEY = ""
Changes to .gitignore ⋯ 4 lines Show the 4 lines above this hunk @@ -5,3 +5,4 @@ vendor 5 5 coverage 6 6 . phpunit . result . cache 7 7 . idea 8 + . env
composer.json modified +6 -4 Changes to composer.json ⋯ 23 lines Show the 23 lines above this hunk @@ -24,8 +24,10 @@24 24 "meema/meema-client-php" : "dev-main" 25 25 } , 26 26 "require-dev" : { 27 - " symfony / var-dumper " : "^ 4 . 3 " , 28 - " phpunit / phpunit " : "^ 8 . 2 " 27 + " orchestra / testbench " : "^ 5 . 0|^6.0 " , 28 + " pestphp / pest " : "^ 1 . 0 " , 29 + "pestphp/pest-plugin-laravel" : "^1.0" , 30 + "phpunit/phpunit" : "^8.0|^9.3" 29 31 } , 30 32 "autoload" : { 31 33 "psr-4" : { ⋯ 15 lines Show the 15 lines above this hunk @@ -47,10 +49,10 @@47 49 "extra" : { 48 50 "laravel" : { 49 51 "providers" : [ 50 - "Meema\\LaravelMeema\\MeemaServiceProvider" 52 + "Meema\\LaravelMeema\\ Providers\\ MeemaServiceProvider" 51 53 ] , 52 54 "aliases" : { 53 - "Meema" : "Meema\\LaravelMeema\\MeemaFacade" 55 + "Meema" : "Meema\\LaravelMeema\\ Facades\\ MeemaFacade" 54 56 } 55 57 } 56 58 }
config/config.php added +8 -0 Changes to config/config.php @@ -0,0 +1,8 @@ 1 + < ? php 2 + 3 + return [ 4 + 5 + 6 + 7 + 'api_key' = > env ( 'PUBLISHABLE_API_KEY' , '' ) , 8 + ] ;
src/Contracts/FavoriteInterface.php deleted +0 -59
src/Contracts/FolderInterface.php deleted +0 -95
src/Contracts/TagInterface.php deleted +0 -50 Changes to src/Contracts/TagInterface.php @@ -1,50 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema \ Contracts ; 4 - 5 - interface TagInterface 6 - { 7 - 8 - 9 - 10 - 11 - 12 - public static function all ( ) : array ; 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - public static function get ( $ids = null ) : array ; 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - public static function find ( $id ) : array ; 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - public static function update ( $id , $color ) : array ; 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - public static function delete ( $ids ) ; 50 - }
src/Facades/Favorite.php added +27 -0 Changes to src/Facades/Favorite.php @@ -0,0 +1,27 @@ 1 + < ? php 2 + 3 + namespace Meema \ LaravelMeema \ Facades ; 4 + 5 + use Illuminate \ Support \ Facades \ Facade ; 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + class Favorite extends Facade 17 + { 18 + 19 + 20 + 21 + 22 + 23 + protected static function getFacadeAccessor ( ) 24 + { 25 + return 'meema-favorite' ; 26 + } 27 + }
src/Facades/Folder.php added +36 -0 Changes to src/Facades/Folder.php @@ -0,0 +1,36 @@ 1 + < ? php 2 + 3 + namespace Meema \ LaravelMeema \ Facades ; 4 + 5 + use Illuminate \ Support \ Facades \ Facade ; 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + class Folder extends Facade 26 + { 27 + 28 + 29 + 30 + 31 + 32 + protected static function getFacadeAccessor ( ) 33 + { 34 + return 'meema-folder' ; 35 + } 36 + }
src/Facades/Meema.php added +28 -0 Changes to src/Facades/Meema.php @@ -0,0 +1,28 @@ 1 + < ? php 2 + 3 + namespace Meema \ LaravelMeema \ Facades ; 4 + 5 + use Illuminate \ Support \ Facades \ Facade ; 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + class Meema extends Facade 18 + { 19 + 20 + 21 + 22 + 23 + 24 + protected static function getFacadeAccessor ( ) 25 + { 26 + return 'meema' ; 27 + } 28 + }
src/Facades/MeemaFavorite.php deleted +0 -19 Changes to src/Facades/MeemaFavorite.php @@ -1,19 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema \ Facades ; 4 - 5 - use Illuminate \ Support \ Facades \ Facade ; 6 - use Meema \ LaravelMeema \ Models \ Favorite ; 7 - 8 - class MeemaFavorite extends Facade 9 - { 10 - 11 - 12 - 13 - 14 - 15 - protected static function getFacadeAccessor ( ) 16 - { 17 - return Favorite : : class ; 18 - } 19 - }
src/Facades/MeemaFolder.php deleted +0 -19 Changes to src/Facades/MeemaFolder.php @@ -1,19 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema \ Facades ; 4 - 5 - use Illuminate \ Support \ Facades \ Facade ; 6 - use Meema \ LaravelMeema \ Models \ Folder ; 7 - 8 - class MeemaFolder extends Facade 9 - { 10 - 11 - 12 - 13 - 14 - 15 - protected static function getFacadeAccessor ( ) 16 - { 17 - return Folder : : class ; 18 - } 19 - }
src/Facades/MeemaTag.php deleted +0 -19 Changes to src/Facades/MeemaTag.php @@ -1,19 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema \ Facades ; 4 - 5 - use Illuminate \ Support \ Facades \ Facade ; 6 - use Meema \ LaravelMeema \ Models \ Tag ; 7 - 8 - class MeemaTag extends Facade 9 - { 10 - 11 - 12 - 13 - 14 - 15 - protected static function getFacadeAccessor ( ) 16 - { 17 - return Tag : : class ; 18 - } 19 - }
src/Facades/Tag.php added +30 -0 Changes to src/Facades/Tag.php @@ -0,0 +1,30 @@ 1 + < ? php 2 + 3 + namespace Meema \ LaravelMeema \ Facades ; 4 + 5 + use Illuminate \ Support \ Facades \ Facade ; 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + class Tag extends Facade 20 + { 21 + 22 + 23 + 24 + 25 + 26 + protected static function getFacadeAccessor ( ) 27 + { 28 + return 'meema-tag' ; 29 + } 30 + }
src/MeemaServiceProvider.php deleted +0 -28 Changes to src/MeemaServiceProvider.php @@ -1,28 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema ; 4 - 5 - use Illuminate \ Support \ ServiceProvider ; 6 - 7 - class MeemaServiceProvider extends ServiceProvider 8 - { 9 - 10 - 11 - 12 - public function boot ( ) 13 - { 14 - if ( $this - > app - > runningInConsole ( ) ) { 15 - $this - > publishes ( [ 16 - __DIR__ . '/../config/config.php' = > config_path ( 'meema.php' ) , 17 - ] , 'config' ) ; 18 - } 19 - } 20 - 21 - 22 - 23 - 24 - public function register ( ) 25 - { 26 - $this - > mergeConfigFrom ( __DIR__ . '/../config/config.php' , 'meema' ) ; 27 - } 28 - }
src/Models/Tag.php deleted +0 -67 Changes to src/Models/Tag.php @@ -1,67 +0,0 @@ 1 - < ? php 2 - 3 - namespace Meema \ LaravelMeema \ Models ; 4 - 5 - use Meema \ LaravelMeema \ Contracts \ TagInterface ; 6 - 7 - class Tag implements TagInterface 8 - { 9 - 10 - 11 - 12 - 13 - 14 - public static function all ( ) : array 15 - { 16 - return [ ] ; 17 - } 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - public static function get ( $ids = null ) : array 27 - { 28 - return [ ] ; 29 - } 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - public static function find ( $id ) : array 39 - { 40 - return [ ] ; 41 - } 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - public static function update ( $id , $color ) : array 52 - { 53 - return [ ] ; 54 - } 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - public static function delete ( $ids ) 64 - { 65 - return [ ] ; 66 - } 67 - }
src/Providers/MeemaServiceProvider.php added +59 -0 Changes to src/Providers/MeemaServiceProvider.php @@ -0,0 +1,59 @@ 1 + < ? php 2 + 3 + namespace Meema \ LaravelMeema \ Providers ; 4 + 5 + use Illuminate \ Support \ ServiceProvider ; 6 + use Meema \ MeemaApi \ Client ; 7 + 8 + class MeemaServiceProvider extends ServiceProvider 9 + { 10 + 11 + 12 + 13 + public function boot ( ) 14 + { 15 + if ( $this - > app - > runningInConsole ( ) ) { 16 + $this - > publishes ( [ 17 + __DIR__ . '/../../config/config.php' = > config_path ( 'meema.php' ) , 18 + ] , 'config' ) ; 19 + } 20 + } 21 + 22 + 23 + 24 + 25 + public function register ( ) 26 + { 27 + $this - > registerMeemaClient ( ) ; 28 + 29 + $this - > app - > bind ( 'meema-media' , function ( $app ) { 30 + return $app [ 'meema' ] - > media ( ) ; 31 + } ) ; 32 + 33 + $this - > app - > bind ( 'meema-folder' , function ( $app ) { 34 + return $app [ 'meema' ] - > folders ( ) ; 35 + } ) ; 36 + 37 + $this - > app - > bind ( 'meema-tag' , function ( $app ) { 38 + return $app [ 'meema' ] - > tags ( ) ; 39 + } ) ; 40 + 41 + $this - > app - > bind ( 'meema-favorite' , function ( $app ) { 42 + return $app [ 'meema' ] - > favorite ( ) ; 43 + } ) ; 44 + 45 + $this - > mergeConfigFrom ( __DIR__ . '/../../config/config.php' , 'meema' ) ; 46 + } 47 + 48 + 49 + 50 + 51 + 52 + 53 + protected function registerMeemaClient ( ) 54 + { 55 + $this - > app - > singleton ( 'meema' , function ( $app ) { 56 + return new Client ( config ( 'meema.api_key' ) ) ; 57 + } ) ; 58 + } 59 + }
tests/ExampleTest.php modified +5 -2 Changes to tests/ExampleTest.php ⋯ 1 line Show the 1 line above this hunk @@ -2,13 +2,16 @@2 2 3 3 namespace Meema \ LaravelMeema \ Tests ; 4 4 5 + use Meema \ LaravelMeema \ Facades \ Meema ; 5 6 use PHPUnit \ Framework \ TestCase ; 6 7 7 8 class ExampleTest extends TestCase 8 9 { 9 10 10 - public function true_is_true ( ) 11 + public function it_can_be_instantiated ( ) 11 12 { 12 - $this - > assertTrue ( true ) ; 13 + $accessKey = Meema : : getAccessKey ( ) ; 14 + 15 + dump ( $accessKey ) ; 13 16 } 14 17 }