Skip to content

Commit

Permalink
format with psr-2
Browse files Browse the repository at this point in the history
  • Loading branch information
orvice committed Nov 29, 2016
1 parent ece813d commit 10cbb1f
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 86 deletions.
17 changes: 7 additions & 10 deletions src/Pongtan/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pongtan;

use Illuminate\Container\Container;
use Pongtan\Services\Config;
use Slim\App as SlimApp;
use Slim\Container as SlimContainer;

Expand All @@ -16,18 +15,18 @@ class App extends SlimApp
*/
private $container;


public static $instance;

/**
* App constructor.
*
* @param $basePath
*/
public function __construct($basePath)
{
$this->setBasePath($basePath);
$this->init();
$container = new SlimContainer;
$container = new SlimContainer();
parent::__construct($container);
self::$instance = $this;
}
Expand All @@ -51,9 +50,8 @@ public function container()
/**
* Register a shared binding in the container.
*
* @param string|array $abstract
* @param \Closure|string|null $concrete
* @return void
* @param string|array $abstract
* @param \Closure|string|null $concrete
*/
public function singleton($abstract, $concrete = null)
{
Expand All @@ -73,7 +71,6 @@ public function init()
$this->container = new Container();
}


/**
* @param $basePath
*/
Expand All @@ -88,19 +85,19 @@ public function setBasePath($basePath)
public function register($serviceClassName)
{
// $service = new \ReflectionClass($serviceClassName);
$service = new $serviceClassName;
$service = new $serviceClassName();
$service->register();
$service->boot();
}

/**
* @param $abstract
* @param array $parameters
*
* @return mixed
*/
public function make($abstract, array $parameters = [])
{
return $this->container->make($abstract, $parameters);
}

}
}
5 changes: 1 addition & 4 deletions src/Pongtan/Cache/Factory.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php


namespace Pongtan\Cache;


class Factory
{

}
}
5 changes: 1 addition & 4 deletions src/Pongtan/Cache/File.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php


namespace Pongtan\Cache;


class File
{

}
}
4 changes: 1 addition & 3 deletions src/Pongtan/Contracts/ServiceProviderInterface.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php


namespace Pongtan\Contracts;


interface ServiceProviderInterface
{
public function register();

public function boot();
}
}
4 changes: 1 addition & 3 deletions src/Pongtan/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Pongtan\Database;


use Illuminate\Database\Eloquent\Model as EloquentModel;

class Model extends EloquentModel
{

}
}
4 changes: 3 additions & 1 deletion src/Pongtan/Facades/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static function getCacheDriver()
* @param $key
* @param $value
* @param $ttl
*
* @return bool
*/
public function set($key, $value, $ttl)
Expand All @@ -27,6 +28,7 @@ public function set($key, $value, $ttl)

/**
* @param $key
*
* @return mixed
*/
public function get($key)
Expand All @@ -41,4 +43,4 @@ public function del($key)
{
return self::getCacheDriver()->delete($key);
}
}
}
8 changes: 5 additions & 3 deletions src/Pongtan/Http/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class Controller
{

protected $app;

protected $ci;
Expand All @@ -19,27 +18,30 @@ public function __construct(ContainerInterface $ci)
$this->ci = $ci;
}


/**
* @param $response
* @param $res
* @param int $statusCode
*
* @return mixed
*/
public function echoJson($response, $res, $statusCode = 200)
{
$newResponse = $response->withJson($res, $statusCode);

return $newResponse;
}

/**
* @param $response
* @param $to
*
* @return mixed
*/
public function redirect($response, $to)
{
$newResponse = $response->withStatus(302)->withHeader('Location', $to);

return $newResponse;
}
}
}
5 changes: 2 additions & 3 deletions src/Pongtan/Providers/CacheServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace Pongtan\Providers;


use Pongtan\SimpleCache\RedisCache;
use Pongtan\Contracts\ServiceProviderInterface;
use Predis\Client;
Expand All @@ -16,11 +14,12 @@ public function register()
// @todo others cache driver support
$config = config('database.redis.default');
$client = new Client($config);

return new RedisCache($client);
});
}

public function boot()
{
}
}
}
18 changes: 9 additions & 9 deletions src/Pongtan/Providers/ConfigServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Pongtan\Providers;

use Illuminate\Filesystem\Filesystem;
Expand All @@ -9,25 +8,26 @@

class ConfigServiceProvider implements ServiceProviderInterface
{

/**
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getEnvironment()
{
$fileSystem = new Filesystem();
$environment = '';
$environmentPath = app()->getBasePath() . '/.env';
$environmentPath = app()->getBasePath().'/.env';
if ($fileSystem->isFile($environmentPath)) {
$environment = trim($fileSystem->get($environmentPath));
$envFile = app()->getBasePath() . '/.' . $environment;
$envFile = app()->getBasePath().'/.'.$environment;

if ($fileSystem->isFile($envFile . '.env')) {
$dotEnv = new Dotenv(app()->getBasePath() . '/', '.' . $environment . '.env');
if ($fileSystem->isFile($envFile.'.env')) {
$dotEnv = new Dotenv(app()->getBasePath().'/', '.'.$environment.'.env');
$dotEnv->load();
}
}

return $environment;
}

Expand All @@ -36,13 +36,13 @@ public function register()
app()->singleton('config', function () {
$config = new Config();
$environment = $this->getEnvironment();
$config->loadConfigFiles(app()->getBasePath() . '/config');
$config->loadConfigFiles(app()->getBasePath().'/config');

return $config;
});
}

public function boot()
{

}
}
}
5 changes: 2 additions & 3 deletions src/Pongtan/Providers/EloquentServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Pongtan\Providers;

use Illuminate\Database\Capsule\Manager as Capsule;
Expand All @@ -14,7 +13,7 @@ public function register()

public function boot()
{
$capsule = new Capsule;
$capsule = new Capsule();
$config = app()->make('config')->get('database.connections');
foreach ($config as $k => $v) {
$capsule->addConnection($v, $k);
Expand All @@ -27,4 +26,4 @@ public function boot()
}
$capsule->bootEloquent();
}
}
}
4 changes: 1 addition & 3 deletions src/Pongtan/Providers/LangServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Pongtan\Providers;

use Pongtan\Services\Factory;
Expand All @@ -17,6 +16,5 @@ public function register()

public function boot()
{

}
}
}
7 changes: 3 additions & 4 deletions src/Pongtan/Providers/LoggerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace Pongtan\Providers;


use Pongtan\Contracts\ServiceProviderInterface;

class LoggerServiceProvider implements ServiceProviderInterface
Expand All @@ -12,12 +10,13 @@ public function register()
{
app()->singleton('log', function () {
$log = new MonoLogger(config('app.name'));
$log->pushHandler(new StreamHandler(app()->getBasePath() . "/storage/logs/fish.log", config('app.log_level')));
$log->pushHandler(new StreamHandler(app()->getBasePath().'/storage/logs/fish.log', config('app.log_level')));

return $log;
});
}

public function boot()
{
}
}
}
4 changes: 2 additions & 2 deletions src/Pongtan/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Pongtan\Providers;

use Pongtan\Contracts\ServiceProviderInterface;
Expand All @@ -20,11 +19,12 @@ public function register()
));
$ext = new PhpFunctionExtension(['config', 'lang']);
$twig->addExtension($ext);

return $twig;
});
}

public function boot()
{
}
}
}
9 changes: 3 additions & 6 deletions src/Pongtan/Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class Config extends Repository
{

/**
* @param $path
*/
Expand All @@ -24,12 +23,10 @@ public function loadConfigFiles($path)
if ($pathInfo['dirname'] == '.') {
$key = $pathInfo['filename'];
} else {
$key = str_replace('/', '.', $pathInfo['dirname']) . '.' . $pathInfo['filename'];
$key = str_replace('/', '.', $pathInfo['dirname']).'.'.$pathInfo['filename'];
}

$this->set($key, require $path . '/' . $relativePathname);
$this->set($key, require $path.'/'.$relativePathname);
}
}


}
}
Loading

0 comments on commit 10cbb1f

Please sign in to comment.