forked from shlinkio/shlink-config
-
Notifications
You must be signed in to change notification settings - Fork 0
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 shlinkio#15 from acelaya-forks/feature/swoole-factory
Added factory that returns a helper to check if swoole is installed
- Loading branch information
Showing
5 changed files
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Config\Factory; | ||
|
||
use function extension_loaded; | ||
|
||
class SwooleInstalledFactory | ||
{ | ||
public const SWOOLE_INSTALLED = 'Shlinkio\Shlink\Config\SwooleInstalled'; | ||
|
||
public function __invoke(): callable | ||
{ | ||
return static fn (): bool => extension_loaded('openswoole') || extension_loaded('swoole'); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Config\Factory; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Shlinkio\Shlink\Config\Factory\SwooleInstalledFactory; | ||
|
||
class SwooleInstalledFactoryTest extends TestCase | ||
{ | ||
private SwooleInstalledFactory $factory; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->factory = new SwooleInstalledFactory(); | ||
} | ||
|
||
/** @test */ | ||
public function properlyCreatesHelperFunction(): void | ||
{ | ||
$func = ($this->factory)(); | ||
|
||
self::assertFalse($func()); | ||
} | ||
} |