Completed
Push — master ( cd44b6...7febf5 )
by MusikAnimal
03:41 queued 01:27
created

ProjectRepository::getUsersInGroups()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 22
nc 2
nop 2
1
<?php
2
/**
3
 * This file contains only the ProjectRepository class.
4
 */
5
6
namespace Xtools;
7
8
use Mediawiki\Api\MediawikiApi;
9
use Mediawiki\Api\SimpleRequest;
10
use Psr\Container\ContainerInterface;
11
12
/**
13
 * This class provides data to the Project class.
14
 */
15
class ProjectRepository extends Repository
16
{
17
    /** @var array Project's 'dbName', 'url' and 'lang'. */
18
    protected $basicInfo;
19
20
    /** @var string[] Basic metadata if XTools is in single-wiki mode. */
21
    protected $singleBasicInfo;
22
23
    /** @var array Full Project metadata, including $basicInfo. */
24
    protected $metadata;
25
26
    /** @var string The cache key for the 'all project' metadata. */
27
    protected $cacheKeyAllProjects = 'allprojects';
28
29
    /**
30
     * Convenience method to get a new Project object based on a given identification string.
31
     * @param string $projectIdent The domain name, database name, or URL of a project.
32
     * @param ContainerInterface $container Symfony's container.
33
     * @return Project
34
     */
35
    public static function getProject($projectIdent, ContainerInterface $container)
36
    {
37
        $project = new Project($projectIdent);
38
        $projectRepo = new ProjectRepository();
39
        $projectRepo->setContainer($container);
0 ignored issues
show
Compatibility introduced by
$container of type object<Psr\Container\ContainerInterface> is not a sub-type of object<Symfony\Component...ncyInjection\Container>. It seems like you assume a concrete implementation of the interface Psr\Container\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
40
        if ($container->getParameter('app.single_wiki')) {
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Container\ContainerInterface as the method getParameter() does only exist in the following implementations of said interface: Container14\ProjectServiceContainer, ProjectServiceContainer, Symfony\Component\DependencyInjection\Container, Symfony\Component\Depend...ection\ContainerBuilder, Symfony\Component\Depend...tainers\CustomContainer, Symfony\Component\Depend...ProjectServiceContainer, Symfony\Component\Depend...ProjectServiceContainer.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
41
            $projectRepo->setSingleBasicInfo([
42
                'url' => $container->getParameter('wiki_url'),
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Container\ContainerInterface as the method getParameter() does only exist in the following implementations of said interface: Container14\ProjectServiceContainer, ProjectServiceContainer, Symfony\Component\DependencyInjection\Container, Symfony\Component\Depend...ection\ContainerBuilder, Symfony\Component\Depend...tainers\CustomContainer, Symfony\Component\Depend...ProjectServiceContainer, Symfony\Component\Depend...ProjectServiceContainer.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
43
                'dbName' => $container->getParameter('database_replica_name'),
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Container\ContainerInterface as the method getParameter() does only exist in the following implementations of said interface: Container14\ProjectServiceContainer, ProjectServiceContainer, Symfony\Component\DependencyInjection\Container, Symfony\Component\Depend...ection\ContainerBuilder, Symfony\Component\Depend...tainers\CustomContainer, Symfony\Component\Depend...ProjectServiceContainer, Symfony\Component\Depend...ProjectServiceContainer.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
44
            ]);
45
        }
46
        $project->setRepository($projectRepo);
47
        return $project;
48
    }
49
50
    /**
51
     * Get the XTools default project.
52
     * @param ContainerInterface $container
53
     * @return Project
54
     */
55
    public static function getDefaultProject(ContainerInterface $container)
56
    {
57
        $defaultProjectName = $container->getParameter('default_project');
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Psr\Container\ContainerInterface as the method getParameter() does only exist in the following implementations of said interface: Container14\ProjectServiceContainer, ProjectServiceContainer, Symfony\Component\DependencyInjection\Container, Symfony\Component\Depend...ection\ContainerBuilder, Symfony\Component\Depend...tainers\CustomContainer, Symfony\Component\Depend...ProjectServiceContainer, Symfony\Component\Depend...ProjectServiceContainer.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
58
        return self::getProject($defaultProjectName, $container);
59
    }
60
61
    /**
62
     * Get the global 'meta' project, which is either Meta (if this is Labs) or the default project.
63
     * @return Project
64
     */
65
    public function getGlobalProject()
66
    {
67
        if ($this->isLabs()) {
68
            return self::getProject('metawiki', $this->container);
69
        } else {
70
            return self::getDefaultProject($this->container);
71
        }
72
    }
73
74
    /**
75
     * For single-wiki installations, you must manually set the wiki URL and database name
76
     * (because there's no meta.wiki database to query).
77
     * @param $metadata
78
     * @throws \Exception
79
     */
80
    public function setSingleBasicInfo($metadata)
81
    {
82
        if (!array_key_exists('url', $metadata) || !array_key_exists('dbName', $metadata)) {
83
            $error = "Single-wiki metadata should contain 'url', 'dbName' and 'lang' keys.";
84
            throw new \Exception($error);
85
        }
86
        $this->singleBasicInfo = array_intersect_key($metadata, [
87
            'url' => '',
88
            'dbName' => '',
89
            'lang' => '',
90
        ]);
91
    }
92
93
    /**
94
     * Get the 'dbName', 'url' and 'lang' of all projects.
95
     * @return string[][] Each item has 'dbName', 'url' and 'lang' keys.
96
     */
97
    public function getAll()
98
    {
99
        $this->log->debug(__METHOD__." Getting all projects' metadata");
100
        // Single wiki mode?
101
        if (!empty($this->singleBasicInfo)) {
102
            return [$this->getOne('')];
0 ignored issues
show
Best Practice introduced by
The expression return array($this->getOne('')); seems to be an array, but some of its elements' types (boolean) are incompatible with the return type documented by Xtools\ProjectRepository::getAll of type string[][].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
103
        }
104
105
        // Maybe we've already fetched it.
106
        if ($this->cache->hasItem($this->cacheKeyAllProjects)) {
107
            return $this->cache->getItem($this->cacheKeyAllProjects)->get();
108
        }
109
110
        // Otherwise, fetch all from the database.
111
        $wikiQuery = $this->getMetaConnection()->createQueryBuilder();
112
        $wikiQuery->select(['dbname AS dbName', 'url', 'lang'])->from('wiki');
113
        $projects = $wikiQuery->execute()->fetchAll();
114
        $projectsMetadata = [];
115
        foreach ($projects as $project) {
116
            $projectsMetadata[$project['dbName']] = $project;
117
        }
118
119
        // Cache and return.
120
        $cacheItem = $this->cache->getItem($this->cacheKeyAllProjects);
121
        $cacheItem->set($projectsMetadata);
122
        $cacheItem->expiresAfter(new \DateInterval('P1D'));
123
        $this->cache->save($cacheItem);
124
        return $projectsMetadata;
125
    }
126
127
    /**
128
     * Get the 'dbName', 'url' and 'lang' of a project. This is all you need
129
     *   to make database queries. More comprehensive metadata can be fetched
130
     *   with getMetadata() at the expense of an API call.
131
     * @param string $project A project URL, domain name, or database name.
132
     * @return string[]|bool With 'dbName', 'url' and 'lang' keys; or false if not found.
133
     */
134
    public function getOne($project)
135
    {
136
        $this->log->debug(__METHOD__." Getting metadata about $project");
137
        // For single-wiki setups, every project is the same.
138
        if (!empty($this->singleBasicInfo)) {
139
            return $this->singleBasicInfo;
140
        }
141
142
        // For muli-wiki setups, first check the cache.
143
        // First the all-projects cache, then the individual one.
144
        if ($this->cache->hasItem($this->cacheKeyAllProjects)) {
145
            foreach ($this->cache->getItem($this->cacheKeyAllProjects)->get() as $projMetadata) {
146
                if ($projMetadata['dbName'] == "$project"
147
                    || $projMetadata['url'] == "$project"
148
                    || $projMetadata['url'] == "https://$project"
149
                    || $projMetadata['url'] == "https://$project.org"
150
                    || $projMetadata['url'] == "https://www.$project") {
151
                    $this->log->debug(__METHOD__ . " Using cached data for $project");
152
                    return $projMetadata;
153
                }
154
            }
155
        }
156
        $cacheKey = "project.$project";
157
        if ($this->cache->hasItem($cacheKey)) {
158
            return $this->cache->getItem($cacheKey)->get();
159
        }
160
161
        // Otherwise, fetch the project's metadata from the meta.wiki table.
162
        $wikiQuery = $this->getMetaConnection()->createQueryBuilder();
163
        $wikiQuery->select(['dbname AS dbName', 'url', 'lang'])
164
            ->from('wiki')
165
            ->where($wikiQuery->expr()->eq('dbname', ':project'))
166
            // The meta database will have the project's URL stored as https://en.wikipedia.org
167
            // so we need to query for it accordingly, trying different variations the user
168
            // might have inputted.
169
            ->orwhere($wikiQuery->expr()->like('url', ':projectUrl'))
170
            ->orwhere($wikiQuery->expr()->like('url', ':projectUrl2'))
171
            ->orwhere($wikiQuery->expr()->like('url', ':projectUrl3'))
172
            ->orwhere($wikiQuery->expr()->like('url', ':projectUrl4'))
173
            ->setParameter('project', $project)
174
            ->setParameter('projectUrl', "https://$project")
175
            ->setParameter('projectUrl2', "https://$project.org")
176
            ->setParameter('projectUrl3', "https://www.$project")
177
            ->setParameter('projectUrl4', "https://www.$project.org");
178
        $wikiStatement = $wikiQuery->execute();
179
180
        // Fetch and cache the wiki data.
181
        $basicInfo = $wikiStatement->fetch();
182
183
        $cacheItem = $this->cache->getItem($cacheKey);
184
        $cacheItem->set($basicInfo)
185
            ->expiresAfter(new \DateInterval('PT1H'));
186
        $this->cache->save($cacheItem);
187
188
        return $basicInfo;
189
    }
190
191
    /**
192
     * Get metadata about a project, including the 'dbName', 'url' and 'lang'
193
     *
194
     * @param string $projectUrl The project's URL.
195
     * @return array|null With 'dbName', 'url', 'lang', 'general' and 'namespaces' keys.
196
     *   'general' contains: 'wikiName', 'articlePath', 'scriptPath', 'script',
197
     *   'timezone', and 'timezoneOffset'; 'namespaces' contains all namespace
198
     *   names, keyed by their IDs.  If this function returns null, the API call
199
     *   failed.
200
     */
201
    public function getMetadata($projectUrl)
202
    {
203
        // First try variable cache
204
        if (!empty($this->metadata)) {
205
            return $this->metadata;
206
        }
207
208
        // Redis cache
209
        $cacheKey = "projectMetadata." . preg_replace("/[^A-Za-z0-9]/", '', $projectUrl);
210
        if ($this->cache->hasItem($cacheKey)) {
211
            $this->metadata = $this->cache->getItem($cacheKey)->get();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->cache->getItem($cacheKey)->get() of type * is incompatible with the declared type array of property $metadata.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
212
            return $this->metadata;
213
        }
214
215
        try {
216
            $api = MediawikiApi::newFromPage($projectUrl);
217
        } catch (\Exception $e) {
218
            return null;
219
        }
220
221
        $params = ['meta' => 'siteinfo', 'siprop' => 'general|namespaces'];
222
        $query = new SimpleRequest('query', $params);
223
224
        $this->metadata = [
225
            'general' => [],
226
            'namespaces' => [],
227
        ];
228
229
        // Even if general info could not be fetched,
230
        //   return dbName, url and lang if already known
231
        if (!empty($this->basicInfo)) {
232
            $this->metadata['dbName'] = $this->basicInfo['dbName'];
233
            $this->metadata['url'] = $this->basicInfo['url'];
234
            $this->metadata['lang'] = $this->basicInfo['lang'];
235
        }
236
237
        $res = $api->getRequest($query);
238
239
        if (isset($res['query']['general'])) {
240
            $info = $res['query']['general'];
241
242
            $this->metadata['dbName'] = $info['wikiid'];
243
            $this->metadata['url'] = $info['server'];
244
            $this->metadata['lang'] = $info['lang'];
245
246
            $this->metadata['general'] = [
247
                'wikiName' => $info['sitename'],
248
                'articlePath' => $info['articlepath'],
249
                'scriptPath' => $info['scriptpath'],
250
                'script' => $info['script'],
251
                'timezone' => $info['timezone'],
252
                'timeOffset' => $info['timeoffset'],
253
                'mainpage' => $info['mainpage'],
254
            ];
255
        }
256
257
        if (isset($res['query']['namespaces'])) {
258
            foreach ($res['query']['namespaces'] as $namespace) {
259
                if ($namespace['id'] < 0) {
260
                    continue;
261
                }
262
263
                if (isset($namespace['name'])) {
264
                    $name = $namespace['name'];
265
                } elseif (isset($namespace['*'])) {
266
                    $name = $namespace['*'];
267
                } else {
268
                    continue;
269
                }
270
271
                $this->metadata['namespaces'][$namespace['id']] = $name;
272
            }
273
        }
274
275
        $cacheItem = $this->cache->getItem($cacheKey);
276
        $cacheItem->set($this->metadata)
277
            ->expiresAfter(new \DateInterval('PT1H'));
278
        $this->cache->save($cacheItem);
279
280
        return $this->metadata;
281
    }
282
283
    /**
284
     * Get a list of projects that have opted in to having all their users' restricted statistics
285
     * available to anyone.
286
     *
287
     * @return string[]
288
     */
289
    public function optedIn()
290
    {
291
        $optedIn = $this->container->getParameter('opted_in');
292
        // In case there's just one given.
293
        if (!is_array($optedIn)) {
294
            $optedIn = [ $optedIn ];
295
        }
296
        return $optedIn;
297
    }
298
299
    /**
300
     * The path to api.php
301
     *
302
     * @return string
303
     */
304
    public function getApiPath()
305
    {
306
        return $this->container->getParameter('api_path');
307
    }
308
309
    /**
310
     * Get a page from the given Project.
311
     * @param Project $project The project.
312
     * @param string $pageName The name of the page.
313
     * @return Page
314
     */
315
    public function getPage(Project $project, $pageName)
316
    {
317
        $pageRepo = new PagesRepository();
318
        $pageRepo->setContainer($this->container);
319
        $page = new Page($project, $pageName);
320
        $page->setRepository($pageRepo);
321
        return $page;
322
    }
323
324
    /**
325
     * Check to see if a page exists on this project and has some content.
326
     * @param Project $project The project.
327
     * @param int $namespaceId The page namespace ID.
328
     * @param string $pageTitle The page title, without namespace.
329
     * @return bool
330
     */
331
    public function pageHasContent(Project $project, $namespaceId, $pageTitle)
332
    {
333
        $conn = $this->getProjectsConnection();
334
        $pageTable = $this->getTableName($project->getDatabaseName(), 'page');
335
        $query = "SELECT page_id "
336
             . " FROM $pageTable "
337
             . " WHERE page_namespace = :ns AND page_title = :title AND page_len > 0 "
338
             . " LIMIT 1";
339
        $params = [
340
            'ns' => $namespaceId,
341
            'title' => $pageTitle,
342
        ];
343
        $pages = $conn->executeQuery($query, $params)->fetchAll();
344
        return count($pages) > 0;
345
    }
346
347
    /**
348
     * Get a list of users who are in one of the given user groups.
349
     * @param  Project $project
350
     * @param  string[] List of user groups to look for.
351
     * @return string[] with keys 'user_name' and 'ug_group'
352
     */
353
    public function getUsersInGroups(Project $project, $groups)
354
    {
355
        $cacheKey = 'usersInGroups.'.$project->getDatabaseName().md5(join($groups));
356
        if ($this->cache->hasItem($cacheKey)) {
357
            return $this->cache->getItem($cacheKey)->get();
358
        }
359
360
        $userTable = $project->getTableName('user');
361
        $userGroupsTable = $project->getTableName('user_groups');
362
363
        $query = $this->getProjectsConnection()->createQueryBuilder();
364
        $query->select(['user_name', 'ug_group'])
365
            ->from($userTable)
366
            ->join($userTable, $userGroupsTable, null, 'ug_user = user_id')
367
            ->where($query->expr()->in('ug_group', ':groups'))
368
            ->groupBy('user_name, ug_group')
369
            ->setParameter(
370
                'groups',
371
                $groups,
372
                \Doctrine\DBAL\Connection::PARAM_STR_ARRAY
373
            );
374
        $admins = $query->execute()->fetchAll();
375
376
        $cacheItem = $this->cache->getItem($cacheKey);
377
        $cacheItem->set($admins)
378
            ->expiresAfter(new \DateInterval('PT1H'));
379
        $this->cache->save($cacheItem);
380
381
        return $admins;
382
    }
383
384
    /**
385
     * Get page assessments configuration for this project
386
     *   and cache in static variable.
387
     * @param string $projectDomain The project domain such as en.wikipedia.org
388
     * @return string[]|bool As defined in config/assessments.yml,
389
     *                       or false if none exists
390
     */
391
    public function getAssessmentsConfig($projectDomain)
392
    {
393
        static $assessmentsConfig = null;
394
        if ($assessmentsConfig !== null) {
395
            return $assessmentsConfig;
396
        }
397
398
        $projectsConfig = $this->container->getParameter('assessments');
399
400
        if (isset($projectsConfig[$projectDomain])) {
401
            $assessmentsConfig = $projectsConfig[$projectDomain];
402
        } else {
403
            $assessmentsConfig = false;
404
        }
405
406
        return $assessmentsConfig;
407
    }
408
}
409