-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
*/ | ||
class Assume | ||
{ | ||
use Extensions\Network; | ||
use Extensions\System; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Assumptions | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @copyright 2015 MehrAlsNix (http://www.mehralsnix.de) | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT | ||
* @link http://github.com/MehrAlsNix/Assumptions | ||
*/ | ||
|
||
namespace MehrAlsNix\Assumptions\Extensions; | ||
|
||
/** | ||
* Trait Network | ||
* @package MehrAlsNix\Assumptions\Extensions | ||
*/ | ||
trait Network | ||
{ | ||
private static $SOCK_ERR_MSG = 'Unable to create socket: '; | ||
|
||
/** | ||
* @param string $address | ||
* @param int $port | ||
*/ | ||
public static function assumeSocket($address, $port = 0) | ||
{ | ||
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | ||
|
||
assumeThat($socket, not(is(false)), self::$SOCK_ERR_MSG . socket_last_error($socket)); | ||
assumeThat(@socket_connect($socket, $address, $port), not(is(false)), 'Unable to connect: ' . $address . ':' . $port); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters