Gemorroj / Archive7z

This library provides handling of 7z files in PHP
GNU Lesser General Public License v3.0
89 stars 20 forks source link

Method for checking 7z executable availability #12

Closed wapmorgan closed 6 years ago

wapmorgan commented 6 years ago

Hello. What do you think about adding a method for performing check that 7z is available?

Gemorroj commented 6 years ago

Can you show similar functionality in other projects or describe why you need this method in real life?

wapmorgan commented 6 years ago

I don't have examples in other projects, but what if for some reason 7z executable disapper from os? Update problems/etc. Just simple isBinaryAvailable() could be called to check it.

Gemorroj commented 6 years ago

You can call null !== $obj7z->getBinary7z(). But in General, there should be no situation when binary path is not available. An exception must be thrown. https://github.com/Gemorroj/Archive7z/blob/68eddc4466906c269809130d2ec9ac3bc2620dd9/src/Archive7z.php#L171-L186

wapmorgan commented 5 years ago

Ok, but now this method seems to be deleted. Can you provide another static one to avoid object creation?

Gemorroj commented 5 years ago

I would suggest, for example, overriding the makeBinary7z method. https://github.com/Gemorroj/Archive7z/blob/40e2f86b0e30fcc80847ec826d15f126a8a35148/src/Archive7z.php#L72-L85 https://github.com/Gemorroj/Archive7z/blob/40e2f86b0e30fcc80847ec826d15f126a8a35148/src/Archive7zTrait.php#L56-L73

The ideology of the library is based on the fact that its base class will be extended.