Completed
Push — master ( 81c6e7...6c71bd )
by Piotr
02:30
created

Messages   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace FSi\Bundle\AdminBundle\Behat\Context\Page\Element;
4
5
use Exception;
6
use SensioLabs\Behat\PageObjectExtension\PageObject\Element;
7
8
class Messages extends Element
9
{
10
    protected $selector = '#messages';
11
12
    public function getMessageText($type)
13
    {
14
        $alerts = $this->findAll('css', sprintf('.alert-%s', $type));
15
        if (count($alerts) < 1) {
16
            throw new Exception(sprintf("Unable to find any alert with type '%s'", $type));
17
        }
18
19
        return implode("\n", array_map(function ($alert) {
20
            return $alert->getText();
21
        }, $alerts));
22
    }
23
}
24