Completed
Push — 259-follow-up ( 71585a )
by Jonathan
01:28
created

BigPipeContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A prepareBigPipeNoJsCookie() 0 14 3
1
<?php
2
3
namespace Drupal\DrupalExtension\Context;
4
5
use Drupal\big_pipe\Render\Placeholder\BigPipeStrategy;
6
use Behat\Mink\Exception\UnsupportedDriverActionException;
7
8
/**
9
 * Big Pipe context.
10
 */
11
class BigPipeContext extends RawDrupalContext
12
{
13
14
    /**
15
     * Prepares Big Pipe NOJS cookie if needed.
16
     *
17
     * @BeforeScenario
18
     */
19
    public function prepareBigPipeNoJsCookie()
20
    {
21
        try {
22
            // Check if JavaScript can be executed by Driver.
23
            $this->getSession()->getDriver()->executeScript('true');
24
        } catch (UnsupportedDriverActionException $e) {
25
            // Set NOJS cookie.
26
            $this
27
              ->getSession()
28
              ->setCookie(BigPipeStrategy::NOJS_COOKIE, true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
        } catch (\Exception $e) {
30
            // Mute exceptions.
31
        }
32
    }
33
}
34