Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Suite / GenericSuite.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Suite;
12
13 use Behat\Testwork\Suite\Exception\ParameterNotFoundException;
14
15 /**
16  * Represents generic (no specific attributes) test suite.
17  *
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
20 final class GenericSuite implements Suite
21 {
22     /**
23      * @var string
24      */
25     private $name;
26     /**
27      * @var array
28      */
29     private $settings = array();
30
31     /**
32      * Initializes suite.
33      *
34      * @param string $name
35      * @param array  $settings
36      */
37     public function __construct($name, array $settings)
38     {
39         $this->name = $name;
40         $this->settings = $settings;
41     }
42
43     /**
44      * Returns unique suite name.
45      *
46      * @return string
47      */
48     public function getName()
49     {
50         return $this->name;
51     }
52
53     /**
54      * Returns suite settings.
55      *
56      * @return array
57      */
58     public function getSettings()
59     {
60         return $this->settings;
61     }
62
63     /**
64      * Checks if a setting with provided name exists.
65      *
66      * @param string $key
67      *
68      * @return Boolean
69      */
70     public function hasSetting($key)
71     {
72         return array_key_exists($key, $this->settings);
73     }
74
75     /**
76      * Returns setting value by its key.
77      *
78      * @param string $key
79      *
80      * @return mixed
81      *
82      * @throws ParameterNotFoundException If setting is not set
83      */
84     public function getSetting($key)
85     {
86         if (!$this->hasSetting($key)) {
87             throw new ParameterNotFoundException(sprintf(
88                 '`%s` suite does not have a `%s` setting.',
89                 $this->getName(),
90                 $key
91             ), $this->getName(), $key);
92         }
93
94         return $this->settings[$key];
95     }
96 }