Coder Social home page Coder Social logo

michael-rubel / laravel-value-objects Goto Github PK

View Code? Open in Web Editor NEW
185.0 4.0 13.0 622 KB

A bunch of general-purpose value objects you can use in your Laravel application.

License: MIT License

PHP 100.00%
laravel looking-for-contributors php value-object value-objects

laravel-value-objects's People

Contributors

bryanlopezinc avatar crynobone avatar dependabot[bot] avatar michael-rubel avatar olsza avatar ramnzys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

laravel-value-objects's Issues

Values object must be immutable

According to the principles of DDD, Values object must be immutable, but here the constructor are public. So i can easily do this.

$test = new Text('value1');
$test->__construct('value2');

echo $test->value; // value2

Shouldn't you protect this method, and make it call from a static method like ValueObject::new($value) ?

FullName doesn’t work with multi-word surnames

My surname is ‘Le Poidevin’ but this gets changed to just ‘Poidevin’.

$name = new FullName('Richard Le Poidevin');

dd($name->toArray());

//
array:3 [
  "fullName" => "Richard Le Poidevin"
  "firstName" => "Richard"
  "lastName" => "Poidevin" // should be: Le Poidevin
]

It’s a tricky one, where should you break, always the first space? Some people may have multiple first names but I think that’s more likely to be hyphenated whilst surnames with ‘Le’ etc. are pretty common. It’s still better than what usually happens to my name - ‘Richard L’ 😅

Maybe the default behaviour should be firstName is the first word and everything else forms lastName?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.