for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
/*
* This file is part of the SmsGate package
*
* (c) SmsGate
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code
*/
namespace SmsGate;
use SmsGate\Exception\InvalidPhoneNumberException;
/**
* The value object for store phone number
* @author Vitaliy Zhuk <[email protected]>
class Phone
{
* @var string
private $value;
* Constructor.
* @param string $value
* @throws InvalidPhoneNumberException
public function __construct(string $value)
if (!preg_match('/^\d+$/', $value)) {
throw new InvalidPhoneNumberException(sprintf(
'Invalid phone number "%s".',
$value
));
}
$this->value = $value;
* Get the value of phone
* @return string
public function getValue(): string
return $this->value;
* Implement __toString
public function __toString(): string