• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-solver / 14341185346

08 Apr 2025 06:42PM UTC coverage: 81.115% (-7.1%) from 88.172%
14341185346

Pull #323

github

eliashaeussler
[FEATURE] Add Claude as additional solution provider
Pull Request #323: [FEATURE] Add Claude as additional solution provider

3 of 92 new or added lines in 5 files covered. (3.26%)

902 of 1112 relevant lines covered (81.12%)

2.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.33
/Classes/Http/ClientFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "solver".
7
 *
8
 * Copyright (C) 2023-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3Solver\Http;
25

26
use Anthropic\Client as AnthropicClient;
27
use EliasHaeussler\Typo3Solver\Configuration;
28
use EliasHaeussler\Typo3Solver\Exception;
29
use OpenAI\Client as OpenAIClient;
30

31
/**
32
 * ClientFactory
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-2.0-or-later
36
 */
37
final class ClientFactory
38
{
39
    public function __construct(
2✔
40
        private readonly Configuration\Configuration $configuration,
41
    ) {}
2✔
42

43
    /**
44
     * @throws Exception\ApiKeyMissingException
45
     */
46
    public function get(): OpenAIClient
2✔
47
    {
48
        $apiKey = $this->configuration->getApiKey();
2✔
49

50
        if ($apiKey === null || \trim($apiKey) === '') {
2✔
51
            throw Exception\ApiKeyMissingException::create();
1✔
52
        }
53

54
        return \OpenAI::client($apiKey);
1✔
55
    }
56

57
    /**
58
     * @throws Exception\ApiKeyMissingException
59
     */
NEW
60
    public function getAnthropicClient(): AnthropicClient
×
61
    {
NEW
62
        $apiKey = $this->configuration->getApiKey();
×
63

NEW
64
        if ($apiKey === null || \trim($apiKey) === '') {
×
NEW
65
            throw Exception\ApiKeyMissingException::create();
×
66
        }
67

NEW
68
        return \Anthropic::client($apiKey);
×
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc