| Conditions | 9 |
| Paths | 128 |
| Total Lines | 29 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 9.0468 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 4 | function __construct($settings) { |
|
| 42 | /** |
||
| 43 | * @var MutexSettings $settings |
||
| 44 | */ |
||
| 45 | 4 | $settings = (object) $settings; |
|
| 46 | 4 | if (!isset($settings->type)) { |
|
|
1 ignored issue
–
show
|
|||
| 47 | 1 | $settings->type = null; |
|
|
1 ignored issue
–
show
|
|||
| 48 | 1 | } |
|
| 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 (isset($settings->prefix)) { |
|
|
1 ignored issue
–
show
|
|||
| 62 | 1 | $prefix = $settings->prefix; |
|
|
1 ignored issue
–
show
|
|||
| 63 | 4 | } elseif ($this->_mutex_type == self::SERVER) { |
|
| 64 | 4 | $prefix = hash('sha512', self::getDomainString()).'_'; |
|
| 65 | 4 | } elseif ($this->_mutex_type == self::DIRECTORY) { |
|
| 66 | 1 | $prefix = hash('sha512', strtolower(self::getDirectoryString())).'_'; |
|
| 67 | 1 | } |
|
| 68 | 4 | $this->filename = $this->_mutex_folder.DIRECTORY_SEPARATOR.'smartmutex_'.$prefix.$this->_mutex_name.'.lock'; |
|
| 69 | 4 | } |
|
| 70 | |||
| 238 | ?> |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: