Completed
Pull Request — develop (#121)
by
unknown
12:28
created

AbstractWriter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toFile() 0 10 2
1
<?php
2
3
namespace Noodlehaus\Writer;
4
5
use Noodlehaus\Exception\WriteException;
6
7
/**
8
 * Base Writer.
9
 *
10
 * @package    Config
11
 * @author     Jesus A. Domingo <[email protected]>
12
 * @author     Hassan Khan <[email protected]>
13
 * @author     Filip Š <[email protected]>
14
 * @author     Mark de Groot <[email protected]>
15
 * @link       https://github.com/noodlehaus/config
16
 * @license    MIT
17
 */
18
abstract class AbstractWriter implements WriterInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function toFile($config, $filename)
24
    {
25
        $contents = $this->toString($config);
26
        $success = @file_put_contents($filename, $contents);
27
        if ($success === false) {
28
            throw new WriteException(['file' => $filename]);
29
        }
30
31
        return $contents;
32
    }
33
}
34