Passed
Pull Request — master (#7302)
by Angel Fernando Quiroz
09:46
created

Version20260102115400::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\Helpers\ScimHelper;
10
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
11
use Doctrine\DBAL\Schema\Schema;
12
13
final class Version20260102115400 extends AbstractMigrationChamilo
14
{
15
    public function getDescription(): string
16
    {
17
        return 'Save SCIM token in .env file';
18
    }
19
20
    public function up(Schema $schema): void
21
    {
22
        $envFilepath = $this->getEnvFilepath();
23
24
        $envFile = file_get_contents($envFilepath);
25
26
        if ($token = ScimHelper::createToken()) {
27
            $newEnvFile = str_replace('{{SCIM_TOKEN}}', $token, $envFile);
28
29
            file_put_contents($envFilepath, $newEnvFile);
30
        }
31
    }
32
33
    public function down(Schema $schema): void
34
    {
35
    }
36
37
    private function getEnvFilepath(): string
38
    {
39
        $rootPath = $this->container->getParameter('kernel.project_dir');
0 ignored issues
show
Bug introduced by
The method getParameter() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        /** @scrutinizer ignore-call */ 
40
        $rootPath = $this->container->getParameter('kernel.project_dir');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
41
        return $rootPath.'/.env';
42
    }
43
}
44