Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dd73bb0

Browse files
committed
Update docs
1 parent 48a3aa9 commit dd73bb0

File tree

12 files changed

+38
-61
lines changed

12 files changed

+38
-61
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Value Objects are PHP [`objects`](http://php.net/manual/en/language.types.object
2222

2323
Simple value objects represent a simple value, like an email. Complex value objects represent complex values, that, in order to really represent a value, need more than one value, like a price that needs an amount and a currency to be understandable and have a sense.
2424

25-
PHP supports only two value object: the [`DateTime`](https://www.php.net/manual/en/class.datetime.php) object and
25+
PHP supports several value object e.g.: the [`DateTime`](https://www.php.net/manual/en/class.datetime.php) object and
2626
[`DateTimeImmutable`](https://www.php.net/manual/ru/class.datetimeimmutable.php) object.
2727

2828
This library gives support for other kind of values.

‎docs/readme.md‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# Guide
2+
Using Value Objects will avoid duplication of code, as well as make your properties more typed.
23

34
## Usage
5+
Value Objects this library are divided into several logical groups:
46

5-
* [Web](usage/web.md)
6-
* [Identity](usage/identity.md)
7-
* [Security](usage/security.md)
8-
* [Person](usage/person.md)
9-
* [Geography](usage/geography.md)
10-
* [Option](usage/option.md)
11-
* [Money](usage/money.md)
12-
* [Payment](usage/payment.md)
13-
* [Content](usage/content.md)
14-
* [Enum](usage/enum.md)
7+
- [Web](usage/web.md)
8+
- [Identity](usage/identity.md)
9+
- [Security](usage/security.md)
10+
- [Person](usage/person.md)
11+
- [Geography](usage/geography.md)
12+
- [Option](usage/option.md)
13+
- [Money](usage/money.md)
14+
- [Payment](usage/payment.md)
15+
- [Content](usage/content.md)
16+
- [Enum](usage/enum.md)
17+
18+
But, this separation is only a structuring of the Value Objects in library. You can use these objects as you discretion.

‎docs/usage/content.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Content
22

3-
## Description
3+
This groups Value Objects use for content, e.g. for blog, news, events.
44

5+
## Description
56
```php
67
use Myks92\ValueObjects\Content\Description;
78

@@ -10,15 +11,14 @@ $description->getValue(); //...
1011
```
1112

1213
## Tag
13-
1414
```php
1515
use Myks92\ValueObjects\Content\Tag;
1616

1717
$tag = new Tag('...');
1818
$tag->getValue(); //...
1919
```
20-
## Title
2120

21+
## Title
2222
```php
2323
use Myks92\ValueObjects\Content\Title;
2424

‎docs/usage/enum.md‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# Enum
2+
This groups Value Objects use for any options, e.g status, role, gender or another objects with key-value.
23

34
## Available Methods
4-
55
* `__construct()` The constructor checks that the value exist in the enum
66
* `__toString()` You can `echo $myValue`, it will display the enum value (value of the constant)
77
* `getValue()` Returns the current value of the enum
88
* `isEqualTo()` Tests whether enum instances are equal (returns `true` if enum values are equal, `false` otherwise)
99

1010
Static methods:
11-
1211
* `toArray()` method Returns all possible values as an array (constant name in key, constant value in value)
1312

14-
## Usage
15-
1613
```php
1714
use Myks92\ValueObjects\Enum\Enum;
1815

‎docs/usage/geography.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Geography
2+
This groups Value Objects use for geography, e.g. for cities, address or for another.
23

34
## Coordinate
45

‎docs/usage/identity.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Identity
2+
This groups Value Objects use for identity, e.g. for auth to users in your project. Or for another Entities.
23

34
## Id
4-
55
```php
66
use Myks92\ValueObjects\Identity\Id;
77
use Ramsey\Uuid\Uuid;
@@ -12,7 +12,6 @@ $id->isEqualTo(new Id(Uuid::uuid4()->toString())); //false
1212
```
1313

1414
## Email
15-
1615
```php
1716
use Myks92\ValueObjects\Identity\Email;
1817

@@ -25,7 +24,6 @@ $email->isEqualTo(new Email('email-other@app.test')); //false
2524
```
2625

2726
## Phone
28-
2927
```php
3028
use Myks92\ValueObjects\Identity\Phone;
3129

@@ -38,7 +36,6 @@ $phone->isEqualTo(new Phone(7, '9997772233')); //false
3836
```
3937

4038
## Network
41-
4239
```php
4340
use Myks92\ValueObjects\Identity\Network;
4441

@@ -50,7 +47,6 @@ $network->isEqualTo(new Network('vk', '11123')); //false
5047
```
5148

5249
## Username
53-
5450
```php
5551
use Myks92\ValueObjects\Identity\Username;
5652

‎docs/usage/money.md‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Money
2+
This groups Value Objects use for work with money.
23

34
## Currency
4-
5-
For job with currency
6-
75
```php
86
use Myks92\ValueObjects\Money\Currency;
97

@@ -13,11 +11,6 @@ $currency->isEqualTo(new Currency('RUB')); //false
1311
```
1412

1513
## Money
16-
17-
For job with money
18-
19-
### Basic
20-
2114
```php
2215
use Myks92\ValueObjects\Money\Money;
2316
use Myks92\ValueObjects\Money\Currency;
@@ -29,13 +22,10 @@ $money->getAmount(); //100
2922
$money->getCurrency()->getValue(); //USD
3023
```
3124

32-
### Calculations
25+
### The Money Value object has embedded calculation methods.
3326

34-
The Money Value object has embedded calculation methods.
35-
36-
#### Add
37-
38-
Add an integer quantity to the amount and returns a new Money object. Use a negative quantity for subtraction.
27+
Add an integer quantity to the amount and returns a new
28+
Money object. Use a negative quantity for subtraction.
3929

4030
```php
4131
use Myks92\ValueObjects\Money\Money;
@@ -48,10 +38,7 @@ $money->add(100); //1300
4838
$money->add(-100); //1200
4939
```
5040

51-
#### Multiply
52-
5341
Represents the multiply value by the given factor
54-
5542
```php
5643
use Myks92\ValueObjects\Money\Money;
5744
use Myks92\ValueObjects\Money\Currency;
@@ -65,8 +52,6 @@ $money = new Money(1200, $currency);
6552
$money->multiply(0.3); //360
6653
```
6754

68-
#### Divide
69-
7055
Represents the divided value by the given factor
7156
```php
7257
use Myks92\ValueObjects\Money\Money;

‎docs/usage/option.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Option
2+
This groups Value Objects use for popular options, which meet in more projects.
23

34
## Role
4-
55
```php
66
use Myks92\ValueObjects\Option\Role;
77

@@ -10,10 +10,11 @@ $role->getValue(); //admin
1010
```
1111

1212
## Status
13-
1413
```php
1514
use Myks92\ValueObjects\Option\Status;
1615

1716
$status = new Status('active');
1817
$status->getValue(); //active
19-
```
18+
```
19+
20+
You can use self the advanced option with help [Enum](enum.md).

‎docs/usage/payment.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Payment
2+
This groups Value Objects use for work with payments.
23

4+
## Payment
35
```php
46
use Myks92\ValueObjects\Payment\Payment;
57

‎docs/usage/person.md‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Person
2+
This groups Value Objects use for person, e.g. for employees, or for any other person in your projects.
23

34
## Birthday
4-
55
```php
66
use Myks92\ValueObjects\Person\Birthday;
77

@@ -11,17 +11,14 @@ $birthday->getDate()->format('Y-m-d'); //2011-01-01
1111
```
1212

1313
## Age
14-
1514
```php
16-
use Myks92\ValueObjects\Person\Birthday;
15+
use Myks92\ValueObjects\Person\Age;
1716

18-
$birthday = new Birthday(new DateTimeImmutable('2011年01月01日'));
19-
$birthday->getAge(); //get age...
20-
$birthday->getDate()->format('Y-m-d'); //2011-01-01
17+
$birthday = new Age(12);
18+
$birthday->getValue(); //12
2119
```
2220

2321
## Gender
24-
2522
```php
2623
use Myks92\ValueObjects\Person\Gender;
2724

@@ -35,7 +32,6 @@ $gender->isEqualTo(new Gender('female')); //false
3532
```
3633

3734
Factory create
38-
3935
```php
4036
use Myks92\ValueObjects\Person\Gender;
4137

@@ -45,7 +41,6 @@ Gender::other()->getValue(); //other
4541
```
4642

4743
## Name
48-
4944
```php
5045
use Myks92\ValueObjects\Person\Name;
5146

@@ -60,7 +55,6 @@ $name->getFull(', '); //Last, First, Middle
6055
```
6156

6257
## Position
63-
6458
```php
6559
use Myks92\ValueObjects\Person\Position;
6660

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /