valueobjects | PHP library/collection of classes / | Functional Programming library

 by   ytake PHP Version: 2.1.0 License: MIT

kandi X-RAY | valueobjects Summary

kandi X-RAY | valueobjects Summary

valueobjects is a PHP library typically used in Programming Style, Functional Programming applications. valueobjects has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

[StyleCI] A PHP library/collection of classes aimed to help developers using and undestanding immutable objects. This is fork of the educational package nicolopignatelli/valueobjects that aims to provide more functionality for basic tasks and act as a object oriented wrapper for PHP types.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              valueobjects has a low active ecosystem.
              It has 52 star(s) with 6 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 1 have been closed. On average issues are closed in 7 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of valueobjects is 2.1.0

            kandi-Quality Quality

              valueobjects has 0 bugs and 0 code smells.

            kandi-Security Security

              valueobjects has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              valueobjects code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              valueobjects is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              valueobjects releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 5123 lines of code, 505 functions and 126 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed valueobjects and discovered the below as its top functions. This is intended to give you an instant insight into valueobjects implemented functionality, and help decide if they suit your requirements.
            • Calculates the distance between this Coordinate .
            • Tells whether two Values are equal
            • Multiplies this Money by the given factor .
            • Returns the number as an integer .
            • Returns a native DateTime instance .
            • Returns a collection of keys .
            • Returns the full name
            • Get IPv6 address version
            • Tells whether two DateTimeWithTimeZone are equal .
            • Create a complex number from polar coordinates .
            Get all kandi verified functions for this library.

            valueobjects Key Features

            No Key Features are available at this moment for valueobjects.

            valueobjects Examples and Code Snippets

            No Code Snippets are available at this moment for valueobjects.

            Community Discussions

            QUESTION

            Testing of even easy behaviour leads to a jungle of testing functions
            Asked 2022-Apr-08 at 12:25

            Until today I had a hard time with unit testing. For this reason I just started to read a book "The art of Unit Testing".
            The author states that each "unit of work" has entry and exit points and that there should be a unit test for each exit point.
            An "exit point" could be:

            • A return value of a function (also an exception)
            • A state change (for example of a class property)
            • A third party system called (E-Mail service)

            The entry point is usually a function call.

            I was now eager to try this in one of my examples and I was successful. But for a price that I cannot accept. My tests are a huge amount of functions and I would like to get your opinion about them.

            The test class I want to use is easy:

            ...

            ANSWER

            Answered 2022-Apr-08 at 12:25

            As you recognize, going down this road will be very painful. Because wanting to assert for each possible case (every parameter value + every possible combination) will require (as you saw) more work than making the actual production code to work.

            All of this because you are orienting tests regarding data.

            If you consider testing the behavior of the system instead, you can break free from a lot of implementation details and focus on a higher level.

            Considering behavior, the only one that I can eventually see is

            The other two parameters should be exclusively set (if one is null, the other must be set and vice versa).

            It corresponds to scenarii 9 and 10 according to your numerotation:

            Source https://stackoverflow.com/questions/71796213

            QUESTION

            MongoDB document version update issue with JaVers
            Asked 2021-Aug-29 at 08:23

            I was using Javers for mongoDB document versioning with springboot. It provides essential functionalities for versioning such as separate history collection called jv_snapshots, changed field list in Entity or ValueObject model for their versions. But I found an issue relevant to valueObjects, but not entities. As you know, the difference between entity and valueObjects is the unique id that identifies the entity, but valueObjects don't have such Id to identify their versions. Refer the following examples as I observed this issue in my use case.

            Let's take the following Entity and valueObject models for versioning.

            Invoice.java

            ...

            ANSWER

            Answered 2021-Aug-29 at 08:23

            If you don't care about ordering, change List to Set in the model. Alternatively, you can configure Javers to use the ListCompareAlgorithm.AS_SET feature.

            In Spring Boot, you can enable it by setting javers.algorithm: AS_SET in your application.yml.

            see https://javers.org/documentation/spring-boot-integration/#javers-configuration-properties

            Source https://stackoverflow.com/questions/68948507

            QUESTION

            EF Core: One to many relationship without navigation property in domain
            Asked 2021-Jul-07 at 12:10

            Hi good people of Internet :)
            I am trying to use EF Core 5 entities as domain entities in a sense of DDD.

            I have a case of two entities, each with their own identity (meaning they are Entity type of DDD objects, not ValueObjects): Country and Currency.

            Currency can belong to many Countries (for example EUR). Country, on the other hand, can have only one 'currently active' Currency, which isn't necessarily the same Currency at all times (such example would be EU country, abandoning their own national currency for the EUR).

            In a specific domain bounded context, I would need only:

            ...

            ANSWER

            Answered 2021-Jul-07 at 12:10

            I am trying to use EF Core 5 entities as domain entities in a sense of DDD.

            EF entities represent the so called data model, which in general is different from domain/business model, has its own requirements/modelling rules which are different from the other models, and navigation properties are great relationship representation which allow producing different type of queries without using manual joins etc.

            So in general you should use separate models and map between the two where needed, thus not "polluting" your domain mode or breaking its rules. Simply the same way you follow the domain model rules, you should follow the data model rules - I don't understand why the people think EF should follow their rules rather than they following EF rules.

            Anyway, with that being said, while super useful, EF Core navigation properties are not mandatory (except currently for many-to-many via implicit junction entity and skip navigations) - you can have both, just principal, just dependent or even neither ends.

            All you need is to define the relationship with the proper Has / With pair. Proper means to use pass the navigation property when exists, and omit it when it doesn't.

            It this case, you could use something like this:

            Source https://stackoverflow.com/questions/68285073

            QUESTION

            Composition of typescript generics
            Asked 2021-Jun-04 at 17:53

            I am trying to create a system for domain modelling in typescript, influenced strongly by Scott Wlaschin's Domain Modelling Made Functional which is based on F#.

            I am having trouble finding the correct way to handle the passing around of generic properties, so that a generic object type can specify a property as being of some form of another generic type with out forcing resolution immediately. Very hard to explain in text so here is a code example of roughly the kind of thing I am trying to achieve:

            ...

            ANSWER

            Answered 2021-Jun-04 at 17:53

            Generic type 'Simple' requires 2 type argument(s).

            You always must supply generic parameters to a generic type. The only exception to that is when those generic parameters have defaults, but that's not the case here.

            What you can do is pass in the original constraints of those generic parameters as a way to say "I do not want to further constrain the generic parameter here"

            Source https://stackoverflow.com/questions/67840909

            QUESTION

            golang: nested struct to nested json or json
            Asked 2021-Apr-26 at 00:21

            I am trying to apply the ddd concepts to my go project

            and then I have an entity with a nested struct like this:

            ...

            ANSWER

            Answered 2021-Apr-26 at 00:21

            Uppercase the first letter of each field of the struct you want to be exportable to json.Marshal:

            Source https://stackoverflow.com/questions/67258952

            QUESTION

            Read model/aggregate code organization in simplified DDD/CQS pattern where read model from other domain is needed
            Asked 2021-Feb-14 at 19:43

            First of all as for "simplified DDD/CQS pattern" I am referencing https://github.com/dotnet-architecture/eShopOnContainers example dotnet application (which is not "strict" DDD/CQRS). However I am not dotnet developer and my question is related to general design patterns / code organization.

            My own case is as follows: I have "conference" domain with "conference" root aggregate and "conference_edition" aggregate. In RDBMS language conference has many editions. In this domain all "communication" with outside world is done through root aggregate "conference". So there are use cases like Conference.create(), Conference.addDraftEdition(), Conference.publishEdition() etc.

            I have also "booking" domain which manages bookings for specific conference editions (people book tickets for a conference edition).

            My question is related to the read model / aggregate of "conference" service (domain?). CMS of this application needs following read model for a conference (example in json for simplicity):

            ...

            ANSWER

            Answered 2021-Feb-14 at 19:43

            Either of the first or second is reasonable. The choice between them will be heavily influenced by how much you want to spread business logic into infrastructure.

            Since the conference and booking domains appear to be different bounded contexts, the third option is really only justifiable if there's some change to a conference edition that's only allowable if bookings are in a certain state.

            Source https://stackoverflow.com/questions/66126094

            QUESTION

            Is custom field option a Valueobject or an Entity in Domain Driven Design
            Asked 2021-Feb-05 at 15:48

            I am using EF Core and I have a scenario where the user can create a custom field and then creates options for that custom fields.

            ...

            ANSWER

            Answered 2021-Jan-30 at 19:02

            Try not to think of persistency details while designing domain model.

            According to your description, CustomFieldOption expresses an individual property with no business relations to any other structure, thus:

            1. it should not hold a business identifier
            2. it should encapsulate its own validations

            Meaning it fits the concept of a value-object (validation inside ctor).

            When it comes to persistency, your repository model should be capable of storing CustomFieldOption objects in a child table (with DB identifier) referencing the parent table (CustomField objects)

            On the query side, repository should be capable of aggregating data from these two tables into a single CustomField entity.

            (How exactly you implement such DB capabilities depends on the ORM you choose to work with, EF in your case)

            Source https://stackoverflow.com/questions/65969819

            QUESTION

            DDD paradigm. Is it possible to use a service from the Infrastructure layer on the Application Core.Domain layer
            Asked 2020-Dec-24 at 08:07

            Sorry for my English, I am writing a real estate appraisal module and decided to try writing in the DDD paradigm. I looked at examples and different articles and formed the following picture for myself (simplified):

            1. ApplicationCore.Domain - the core of business logic, contains all the necessary objects divided into 2 typesа
              Entitys - if an entity needs to be stored in a database and it is a ready-made complete business logic object. ValueObjects - all other properties that encapsulate the behavior, are compared by the value of the fields, and are part of Entity It is very important to create only valid objects, so I create everything through factories with a validator, and the constructors are private. There should be no references to other dependencies, as isolated as possible.

            2. ApplicationCore.App - a layer above ApplicationCore.Domain, contains a link to it. works with objects from ApplicationCore.Domain and uses external services through Port/Adapter. Port - For example, an abstraction of a repository, its implementation through an Adapter on the Infrastructure layer.
              interaction logic for ApplicationCore is in AppServices - for classic implementation or in Command / Request - for CQRS

            3. Infrastructure - contains a link to ApplicationCore.Domain and ApplicationCore.App. Implements the ports of the ApplicationCore.App layer

            Entities are independent from each other and refer to each other by keys for interaction. I kept the basic logic of the assessment system in this paradigm. But here it was necessary to add a service that receives additional information for evaluation from different sources, while in wiretapping mode. Those. Works against the background of listening to TcpIp socket

            Service settings are stored in the database and change frequently - i.e. you need to introduce a new Entity A chain is formed

            ...

            ANSWER

            Answered 2020-Dec-24 at 08:07

            I've to admit that is a bit hard to understand everything. Especially at the end, you speak about object that isn't clear where they are and what they do.

            Anyway, you cannot use anything for the layer above (infrastructure) into the layers below (application and domain). I don't know how would you do it, but as a simple dependency it would not leave you compile any project. You'll end with a circular dependency.

            Given that you would not do this, you can build a service (I do it with static functions to avoid any kind of unwanted implementation) into the domain layer. That service use interfaces that are implemented into the application layer. Into the application layer you'll also use (or reuse) interfaces that will be implemented into the infrastructure layer.

            Source https://stackoverflow.com/questions/65421849

            QUESTION

            Custom Equality check for C# 9 records
            Asked 2020-Oct-13 at 08:22

            From what I understand, records are actually classes that implement their own equality check in a way that your object is value-driven and not reference driven.

            In short, for the record Foo that is implemented like so: var foo = new Foo { Value = "foo" } and var bar = new Foo { Value = "foo" }, the foo == bar expression will result in True, even though they have a different reference (ReferenceEquals(foo, bar) // False).

            Now with records, even though that in the article posted in .Net Blog, it says:

            If you don’t like the default field-by-field comparison behavior of the generated Equals override, you can write your own instead.

            When I tried to place public override bool Equals, or public override int GetHashCode, or public static bool operator ==, and etc. I was getting Member with the same signature is already declared error, so I think that it is a restricted behaviour, which isn't the case with struct objects.

            Failing example:

            ...

            ANSWER

            Answered 2020-Oct-13 at 02:50

            Per the C#9 record proposal, the following should compile, even if not very useful without actual implementations..

            Source https://stackoverflow.com/questions/64326511

            QUESTION

            Are aggregates and aggregate roots implemented as separate classes?
            Asked 2020-Aug-19 at 16:02

            With so much talk about DDD, I've expected to find lot of code examples how these patterns are implemented. But wasn't so lucky.

            What confuses me is this. Is an aggregate kind of entity, represented as aggregate root, or are those implemented as separate classes? Here are few examples, please answer if any of them is true.

            1. They are separate classes
            ...

            ANSWER

            Answered 2020-Aug-19 at 16:02

            There is no separate aggregate class, but aggregate root class, which represents the aggregate

            This one.

            The reference book that introduced DDD, and the "aggregate" pattern, is Eric Evans Domain Driven Design: Tackling Complexity int the Heart of Software.

            Chapter 5 discusses patterns used in modeling a domain in software: entities, values, "domain services", and so on.

            Chapter 6 discusses life cycle management, where he talks about factories, repositories, and aggregates:

            An AGGREGATE is a cluster of of associated objects we treat as a unit for the purpose of data changes. Each aggregate has a root and a boundary. The boundary defines what is inside the aggregate. The root is a single, specific ENTITY contained in the aggregate. The root is the only member of the AGGREGATE that outside objects are allowed to hold references to....

            If you like, an aggregate is a graph of objects, which includes the root object, and the other objects that you can reach from the root object by traversing local references.

            Source https://stackoverflow.com/questions/63488232

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install valueobjects

            required >= PHP 7.0.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/ytake/valueobjects.git

          • CLI

            gh repo clone ytake/valueobjects

          • sshUrl

            git@github.com:ytake/valueobjects.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link