Passed
Push — master ( bec3a0...d17744 )
by 世昌
01:55
created

CollectionFile::getIterator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace nebula\route\collection;
3
4
use Iterator;
5
use IteratorAggregate;
6
7
/**
8
 * 路由集合文件
9
 */
10
class CollectionFile
11
{
12
13
    public static function fromFile(string $path)
14
    {
15
        return \unserialize(\file_get_contents($path));
16
    }
17
18
    /**
19
     * 保存到文件
20
     *
21
     * @param string $path
22
     * @return boolean
23
     */
24
    public function save(string $path):bool
25
    {
26
        return \file_put_contents($path, \serialize($this));
0 ignored issues
show
Bug Best Practice introduced by
The expression return file_put_contents($path, serialize($this)) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
27
    }
28
}
29