UpsertPlugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 4 1
A handle() 0 4 2
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Services\Filesystem\Plugins;
14
15
use League\Flysystem\Plugin\AbstractPlugin;
16
17
/**
18
 * Puts contents into a file if it exists, if not create it.
19
 */
20
class UpsertPlugin extends AbstractPlugin
21
{
22
    /**
23
     * Get the method name.
24
     *
25
     * @return string
26
     */
27 442
    public function getMethod()
28
    {
29 442
        return 'upsert';
30
    }
31
32
    /**
33
     * @param string $filename
34
     * @param string $contents
35
     *
36
     * @return bool
37
     */
38 7
    public function handle($filename, $contents)
39
    {
40 7
        return $this->filesystem->has($filename) ? $this->filesystem->update($filename, $contents) : $this->filesystem->write($filename, $contents);
41
    }
42
}
43