Passed
Pull Request — master (#577)
by Dmitriy
09:18
created

HomeController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 36 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use Psr\Http\Message\ResponseFactoryInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseFactoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Psr\Http\Message\StreamFactoryInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\StreamFactoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Yiisoft\Router\UrlGeneratorInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Router\UrlGeneratorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class HomeController
13
{
14
    public function index(
15
        ResponseFactoryInterface $responseFactory,
16
        StreamFactoryInterface $streamFactory,
17
        UrlGeneratorInterface $urlGenerator
18
    ): ResponseInterface {
19
        $urlParameters = ['name' => 'World'];
20
        $simpleActionUrl = $urlGenerator->generate('temporal/simple', $urlParameters);
21
        $complicatedActionUrl = $urlGenerator->generate('temporal/complicated', $urlParameters);
22
        $asynchronousActionUrl = $urlGenerator->generate('temporal/asynchronous', $urlParameters);
23
24
        $response = <<<HTML
25
            This project is example how to use Temporal with Yii 3 application.
26
            <br>
27
            There are exist several examples how it works.
28
            <br>
29
            <h3>Examples:</h3>
30
            If you want to see how "simple" workflow works <a href="{$simpleActionUrl}" target="_blank">click here</a>.
31
            <br>
32
            There is usual call non-blocking action. It should work as faster as you can run usual php code.
33
            <br>
34
            If you want to see how "complicated" workflow works <a href="{$complicatedActionUrl}" target="_blank">click here</a>.
35
            <br>
36
            There are imitation for blocking action. Different methods calls will run with random delay: from 1 to 5 seconds per call.
37
            <br>
38
            If you want to see how "deferred" workflow works <a href="{$asynchronousActionUrl}" target="_blank">click here</a>.
39
            <br>
40
            There are imitation for asynchronous action. You will get "job id" and you can track the status in another endpoint.<br>
41
            Logic for workflow will be same as "complicated" workflow.
42
            <br>
43
            HTML;
44
45
        return $responseFactory->createResponse(200)
46
            ->withBody(
47
                $streamFactory->createStream($response)
48
            )
49
            ->withHeader('Content-Type', 'text/html')
50
        ;
51
    }
52
}
53