Passed
Branch master (bbfb46)
by Jan
22:41 queued 14:44
created

TestController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2
1
<?php declare(strict_types=1);
2
3
namespace SwagExample\Controller;
4
5
use League\Flysystem\FilesystemInterface;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Routing\Annotation\Route;
9
10
class TestController extends AbstractController
11
{
12
    /**
13
     * @var FilesystemInterface
14
     */
15
    private $privateFilesystem;
16
17
    /**
18
     * @var FilesystemInterface
19
     */
20
    private $publicFilesystem;
21
22
    public function __construct(FilesystemInterface $privateFilesystem, FilesystemInterface $publicFilesystem)
23
    {
24
        $this->privateFilesystem = $privateFilesystem;
25
        $this->publicFilesystem = $publicFilesystem;
26
    }
27
28
    /**
29
     * @Route("/test-filesystem", name="test.filesystem", methods={"GET"})
30
     */
31
    public function testFilesystem(): Response
32
    {
33
        $this->privateFilesystem->write('test.txt', 'foo bar private');
34
        $this->publicFilesystem->write('test.txt', 'foo bar public');
35
36
        $privateTest = $this->privateFilesystem->read('test.txt');
37
        $publicTest = $this->publicFilesystem->read('test.txt');
38
39
        return new Response($privateTest . '<br>' . $publicTest);
40
    }
41
}
42