RawMinkContext   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 3 1
A getContainer() 0 3 1
A assertElementType() 0 5 2
1
<?php
2
3
namespace NuvoleWeb\Drupal\DrupalExtension\Context;
4
5
use Behat\Behat\Context\SnippetAcceptingContext;
6
use Behat\Mink\Element\NodeElement;
7
use Behat\Mink\Exception\ExpectationException;
8
use Behat\MinkExtension\Context\RawMinkContext as OriginalRawMinkContext;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
/**
12
 * Class RawMinkContext.
13
 *
14
 * @package NuvoleWeb\Drupal\DrupalExtension\Context
15
 */
16
class RawMinkContext extends OriginalRawMinkContext implements ServiceContainerAwareInterface, SnippetAcceptingContext {
0 ignored issues
show
Deprecated Code introduced by
The interface Behat\Behat\Context\SnippetAcceptingContext has been deprecated with message: will be removed in 4.0. Use --snippets-for CLI option instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
18
  /**
19
   * Service container instance.
20
   *
21
   * @var ContainerBuilder
22
   */
23
  private $container;
24
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function setContainer(ContainerBuilder $container) {
29
    $this->container = $container;
30
  }
31
32
  /**
33
   * {@inheritdoc}
34
   */
35
  public function getContainer() {
36
    return $this->container;
37
  }
38
39
  /**
40
   * Checks that the given element is of the given type.
41
   *
42
   * @param NodeElement $element
43
   *   The element to check.
44
   * @param string $type
45
   *   The expected type.
46
   *
47
   * @throws ExpectationException
48
   *   Thrown when the given element is not of the expected type.
49
   */
50
  public function assertElementType(NodeElement $element, $type) {
51
    if ($element->getTagName() !== $type) {
52
      throw new ExpectationException("The element is not a '$type'' field.", $this->getSession());
53
    }
54
  }
55
56
}
57