Comments (4)
@Zolli In PHP instances of the same class can access their private properties. This is a feature of PHP, not a bug.
So.
<?php
class MyObject {
private $property = 'x';
public function equals(MyObject $object) {
// because $object and $this are of the same class (MyObject)
// the property can be accessed even though it is private
// this is because php only prohibits other *classes* - and thus not instances - to access private properties
return $this->property === $object->property;
}
}
from mail.
Oh, sorry about that. I dont use this feature very often.
from mail.
No problem. You might also have a look at the tests. This functionality is tested here.
Otherwise, I might also recommend reading upon value objects, or specific for PHP. In this case EmailAddresss
is a value object. One of the characteristics of a value object is that their equality is based on the value, not on identity.
So.
$address1 = new EmailAddress('[email protected]');
$address2 = new EmailAddress('[email protected]');
$address3 = new EmailAddress('[email protected]');
$address1->equals($address2); // true
$address1->equals($address3); // false
This is different from entities and models. For models and entities the equality is based on the id of the object.
$user1 = new User(['id' => 1]);
$user2 = new User(['id' => 2]);
$user3 = new User(['id' => 3]);
$user1->equals($user2); // true
$user1->equals($user3); // false
Hope it helps understanding the concept! It is really valuable (!)
from mail.
@frederikbosch, I understand the concept, only those private access from the same type behavior not. Thanks for write this down. This could be very useful.
from mail.
Related Issues (20)
- Buffing the initial readme documentation HOT 2
- Consider renaming factories HOT 1
- ssl custom context stream options HOT 4
- QueueProcessor should catch any protocol exception instead of only ConnectionRefusedException
- Too many constructors HOT 4
- ContentID enhancement HOT 1
- Base64 and Quoted Printable Streams produce different results HOT 1
- Server class not correctly handling unknown SMTP commands HOT 4
- How to send a mail using SMTP? HOT 5
- Support RFC 2646 / 3676 HOT 1
- Add JMAP support (as an alternative to IMAP + SMTP, and later to CardDAV/CalDAV) HOT 2
- Currently charset = us-ascii, how to set another one? HOT 2
- Angle brackets by default in Content-ID and Message-ID headers HOT 1
- Support internationalized email addresses (RFC 6530) HOT 1
- A request for help and an example of SearchCommand
- UTF-8, invalid characters as a result of AlternativeText HOT 1
- PHP 8+ support HOT 3
- How to add attachments to PlainTextMessage HOT 7
- About the encoding of AlternativeText HOT 4
- Long Japanese subject fails to decode on some mailers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mail.