| Total Complexity | 8 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Profile |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $ssid; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $securityType; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Service constructor. |
||
| 24 | * |
||
| 25 | * @param string $ssid |
||
| 26 | * @param string $securityType |
||
| 27 | */ |
||
| 28 | public function __construct(string $ssid, string $securityType) |
||
| 29 | { |
||
| 30 | $this->ssid = $ssid; |
||
| 31 | $this->securityType = $securityType; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param string $password |
||
| 36 | * |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | public function create(string $password): string |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Delete tmp profile file created for chosen network. |
||
| 48 | */ |
||
| 49 | public function delete(): bool |
||
| 50 | { |
||
| 51 | $tmpProfile = $this->getTmpFileName(); |
||
| 52 | |||
| 53 | if (file_exists($tmpProfile)) { |
||
| 54 | return unlink($tmpProfile); |
||
| 55 | } |
||
| 56 | |||
| 57 | return false; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | protected function getTmpFileName(): string |
||
| 64 | { |
||
| 65 | return __DIR__.'/../../../tmp/'.$this->ssid.'.xml'; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | protected function getTemplateFileName(): string |
||
| 72 | { |
||
| 73 | return __DIR__.'/../../../templates/'.$this->securityType.'.xml'; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param string $password |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | protected function renderTemplate(string $password): string |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | } |
||
| 100 |