Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhndev/value-objects
common value Objects such as Email and Phone , ...
https://github.com/mhndev/value-objects
value-object
Last synced: 2 months ago
JSON representation
common value Objects such as Email and Phone , ...
- Host: GitHub
- URL: https://github.com/mhndev/value-objects
- Owner: mhndev
- Created: 2017-02-17T17:38:58.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2018-11-20T14:22:05.000Z (about 6 years ago)
- Last Synced: 2024-05-04T09:00:46.185Z (9 months ago)
- Topics: value-object
- Language: PHP
- Size: 26.4 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Common Value Objects
##### Common mostly used Value Objects I confronted through my own Projects
##### sample codes
```php
use mhndev\valueObjects\implementations\Email;
use mhndev\valueObjects\implementations\MobilePhone;
use mhndev\valueObjects\implementations\Token;
use mhndev\valueObjects\implementations\Version;$mobileObject = MobilePhone::fromOptions('989124444444');
echo $mobileObject->format(MobilePhone::WithZero);
### output : 09124444444
echo $mobileObject->format(MobilePhone::WithoutZero);
### output : 9124444444
echo $mobileObject->isMCI(MobilePhone::WithoutZero);
### output : true
echo $mobileObject->isMTN(MobilePhone::WithoutZero);
### output : false
$emailObject = new Email('[email protected]');
echo $emailObject->getDomain();
### output : example.com
echo $emailObject->getLocal();
### output : info
$tokenObject = new Token(
'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImVhMTY3OTQ',
Token::SCHEMA_Bearer,
6000
);echo $tokenObject->getType();
### output : Bearer
echo $tokenObject->getExpiresAt()->format('Y-m-d H:i:s');
### output : 2018-12-03 08:05:22
$port = Version::fromString('6.5.0');
echo $port->getMajor();
### output : 6echo $port->getMinor();
### output : 0echo $port->getPatch();
### output : 5```
#### you can find more examples by digging in source.