MemoryFileTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A makeFile() 0 8 2
1
<?php
2
/**
3
 * This file is part of graze/data-flow
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.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
 * @license https://github.com/graze/data-flow/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-flow
12
 */
13
14
namespace Graze\DataFlow\Test;
15
16
use Graze\DataFile\Node\FileNode;
17
use League\Flysystem\Filesystem;
18
use League\Flysystem\Memory\MemoryAdapter;
19
20
abstract class MemoryFileTestCase extends TestCase
21
{
22
    /**
23
     * @var Filesystem
24
     */
25
    private $filesystem;
26
27
    protected function setUp()
28
    {
29
        $this->filesystem = new Filesystem(new MemoryAdapter());
30
    }
31
32
    /**
33
     * @param string      $path
34
     * @param string|null $contents
35
     *
36
     * @return FileNode
37
     */
38
    protected function makeFile($path, $contents = null)
39
    {
40
        $file = new FileNode($this->filesystem, $path);
41
        if (!is_null($contents)) {
42
            $file->write($contents);
43
        }
44
        return $file;
45
    }
46
}
47