Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
20.00% |
1 / 5 |
CRAP | |
20.00% |
2 / 10 |
| StorageBase | |
0.00% |
0 / 1 |
|
20.00% |
1 / 5 |
32.09 | |
20.00% |
2 / 10 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getCollectionName | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| get | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 2 |
|||
| setMultiple | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| delete | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Core\KeyValueStore\StorageBase. | |
| */ | |
| namespace Drupal\Core\KeyValueStore; | |
| /** | |
| * Provides a base class for key/value storage implementations. | |
| */ | |
| abstract class StorageBase implements KeyValueStoreInterface { | |
| /** | |
| * The name of the collection holding key and value pairs. | |
| * | |
| * @var string | |
| */ | |
| protected $collection; | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function __construct($collection) { | |
| $this->collection = $collection; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getCollectionName() { | |
| return $this->collection; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function get($key, $default = NULL) { | |
| $values = $this->getMultiple(array($key)); | |
| return isset($values[$key]) ? $values[$key] : $default; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function setMultiple(array $data) { | |
| foreach ($data as $key => $value) { | |
| $this->set($key, $value); | |
| } | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function delete($key) { | |
| $this->deleteMultiple(array($key)); | |
| } | |
| } |