| Conditions | 8 |
| Paths | 96 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 8.3844 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 4 | function __construct($settings) { |
|
|
1 ignored issue
–
show
|
|||
| 42 | /** |
||
| 43 | * @var MutexSettings $settings |
||
| 44 | */ |
||
| 45 | 4 | $settings = (object) $settings; |
|
| 46 | 4 | if (!isset($settings->type)) { |
|
|
1 ignored issue
–
show
|
|||
| 47 | $settings->type = null; |
||
|
1 ignored issue
–
show
|
|||
| 48 | } |
||
| 49 | 4 | if (!isset($settings->folder)) { |
|
|
1 ignored issue
–
show
|
|||
| 50 | 1 | $settings->folder = null; |
|
|
1 ignored issue
–
show
|
|||
| 51 | 1 | } |
|
| 52 | |||
| 53 | 4 | $this->_mutex_type = is_null($settings->type) ? self::SERVER : $settings->type; |
|
|
1 ignored issue
–
show
|
|||
| 54 | 4 | $this->_mutex_folder = is_null($settings->folder) ? sys_get_temp_dir() : $settings->folder; |
|
|
1 ignored issue
–
show
|
|||
| 55 | 4 | $this->_mutex_name = $settings->name; |
|
|
1 ignored issue
–
show
|
|||
| 56 | 4 | if (isset($settings->delete_on_release)) { |
|
|
1 ignored issue
–
show
|
|||
| 57 | $this->_delete_on_release = $settings->delete_on_release; |
||
|
1 ignored issue
–
show
|
|||
| 58 | } |
||
| 59 | |||
| 60 | 4 | $prefix = ''; |
|
| 61 | 4 | if ($this->_mutex_type == self::SERVER) { |
|
| 62 | 4 | $prefix = hash('sha512', self::getDomainString()).'_'; |
|
| 63 | 4 | } elseif ($this->_mutex_type == self::DIRECTORY) { |
|
| 64 | 1 | $prefix = hash('sha512', strtolower(self::getDirectoryString())).'_'; |
|
| 65 | 1 | } |
|
| 66 | 4 | $this->filename = $this->_mutex_folder.DIRECTORY_SEPARATOR.'smartmutex_'.$prefix.$this->_mutex_name.'.lock'; |
|
| 67 | 4 | } |
|
| 68 | |||
| 236 | ?> |
||
|
1 ignored issue
–
show
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.