FileTempObject::fromString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Jackal\ImageMerge\Model\File;
4
5
class FileTempObject extends FileObject
6
{
7
    public static function fromString($content)
8
    {
9
        $path = Filename::createTempFilename();
10
11
        $o = new self($path, 'w+');
12
        $o->fwrite($content);
13
        $o->seek(0);
14
15
        return $o;
16
    }
17
18
    public function __destruct()
19
    {
20
        if (is_file($this->getPathname())) {
21
            unlink($this->getPathname());
22
        }
23
    }
24
}
25