-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a484f2
commit 1d7c9eb
Showing
24 changed files
with
286 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor | ||
var | ||
bin | ||
.idea |
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,45 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/../') | ||
->exclude( | ||
[ | ||
'var', | ||
'node_modules', | ||
'upgrades', | ||
] | ||
)->notPath( | ||
[ | ||
'public/index.php', | ||
'public/api.php', | ||
'config/bootstrap.php', | ||
'src/Kernel.php', | ||
] | ||
); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setCacheFile(__DIR__ . '/../var/.php_cs.cache') | ||
->setRules( | ||
[ | ||
'@PSR12' => true, | ||
'blank_line_after_opening_tag' => true, | ||
'braces' => ['allow_single_line_closure' => true], | ||
'compact_nullable_typehint' => true, | ||
'single_quote' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'declare_equal_normalize' => ['space' => 'none'], | ||
'function_typehint_space' => true, | ||
'new_with_braces' => true, | ||
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], | ||
'no_empty_statement' => true, | ||
'no_leading_import_slash' => true, | ||
'no_leading_namespace_whitespace' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'return_type_declaration' => ['space_before' => 'none'], | ||
'single_trait_insert_per_statement' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true], | ||
'declare_strict_types' => true | ||
] | ||
) | ||
->setFinder($finder); |
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,6 @@ | ||
parameters: | ||
level: 6 | ||
paths: | ||
- ../src | ||
#- ../tests | ||
tmpDir: ../var/phpstan |
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="../tests/bootstrap.php" cacheResultFile="../var/.phpunit.result.cache" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
<server name="APP_ENV" value="test" force="true"/> | ||
<server name="SHELL_VERBOSITY" value="-1"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>../tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macopedia\Translator\Client\OpenAiClient; | ||
|
||
class Message | ||
{ | ||
public function __construct( | ||
private string $role, | ||
private string $content | ||
) {} | ||
) { | ||
} | ||
|
||
public function getContent(): string | ||
{ | ||
return $this->content; | ||
} | ||
} | ||
} |
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
10 changes: 7 additions & 3 deletions
10
src/Macopedia/Translator/Exception/InvalidOpenAiResponseException.php
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macopedia\Translator\Exception; | ||
|
||
class InvalidOpenAiResponseException extends \Exception | ||
use Exception; | ||
|
||
class InvalidOpenAiResponseException extends Exception | ||
{ | ||
public function __construct() | ||
public function __construct(array $request) | ||
{ | ||
parent::__construct('Response from OpenAi is empty'); | ||
parent::__construct(sprintf('Response from OpenAi is empty. Request: %s', json_encode($request))); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Macopedia\Translator; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
Oops, something went wrong.