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

DoclerLabs / api-client-generator / 7259428899

19 Dec 2023 08:47AM UTC coverage: 89.733% (-0.3%) from 90.043%
7259428899

push

github

web-flow
Merge pull request #102 from DoclerLabs/generator-php-8

generator php 8

355 of 381 new or added lines in 40 files covered. (93.18%)

6 existing lines in 4 files now uncovered.

2657 of 2961 relevant lines covered (89.73%)

3.35 hits per line

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

48.0
/src/Generator/Security/BearerAuthenticationSecurityStrategy.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace DoclerLabs\ApiClientGenerator\Generator\Security;
6

7
use DoclerLabs\ApiClientGenerator\Entity\Operation;
8
use DoclerLabs\ApiClientGenerator\Input\Specification;
9
use PhpParser\Node\Expr;
10

11
class BearerAuthenticationSecurityStrategy extends SecurityStrategyAbstract
12
{
13
    private const PROPERTY_NAME = 'bearerToken';
14

15
    private const SCHEME = 'bearer';
16

17
    private const TYPE = 'http';
18

19
    public function getProperties(Operation $operation, Specification $specification): array
20
    {
21
        if ($this->phpVersion->isConstructorPropertyPromotionSupported()) {
1✔
NEW
22
            return [];
×
23
        }
24

25
        $statements = [];
1✔
26

27
        if ($this->isAuthenticationAvailable($operation, $specification)) {
1✔
28
            $statements[] = $this->builder->localProperty(self::PROPERTY_NAME, 'string', 'string');
×
29
        }
30

31
        return $statements;
1✔
32
    }
33

34
    public function getConstructorParams(Operation $operation, Specification $specification): array
35
    {
36
        $params = [];
1✔
37

38
        if ($this->isAuthenticationAvailable($operation, $specification)) {
1✔
39
            $params[] = $this->builder
×
40
                ->param(self::PROPERTY_NAME)
×
NEW
41
                ->setType('string');
×
42
        }
43

44
        return $params;
1✔
45
    }
46

47
    public function getConstructorParamInits(Operation $operation, Specification $specification): array
48
    {
49
        if ($this->phpVersion->isConstructorPropertyPromotionSupported()) {
1✔
NEW
50
            return [];
×
51
        }
52

53
        $paramInits = [];
1✔
54

55
        if ($this->isAuthenticationAvailable($operation, $specification)) {
1✔
56
            $paramInits[] = $this->builder->assign(
×
57
                $this->builder->localPropertyFetch(self::PROPERTY_NAME),
×
58
                $this->builder->var(self::PROPERTY_NAME)
×
59
            );
60
        }
61

62
        return $paramInits;
1✔
63
    }
64

65
    protected function getScheme(): string
66
    {
67
        return self::SCHEME;
1✔
68
    }
69

70
    protected function getType(): string
71
    {
72
        return self::TYPE;
×
73
    }
74

75
    protected function getAuthorizationHeader(): Expr
76
    {
77
        return $this->builder->funcCall(
×
78
            'sprintf',
×
79
            ['Bearer %s', $this->builder->localPropertyFetch(self::PROPERTY_NAME)]
×
80
        );
81
    }
82
}
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