Giter Site home page Giter Site logo

Comments (4)

oschwald avatar oschwald commented on August 25, 2024

The objects are intentionally immutable. A reset method would be contrary to that. The with*() calls do not change the underlying object but create a new one. As such, if you want to reuse the object created by the constructor, i.e., when you call new MinFraud(...), between calls, you can. You just need to save it to a different variable.

from minfraud-api-php.

Gamesh avatar Gamesh commented on August 25, 2024

@oschwald yeah, i know, but that does not work in most modern frameworks that use dependency injection. Also if i'm creating an instance of MinFraud that leaves my service untestable as it no longer uses DI and that dependency can't be mocked. We then have to resort to hacks like setters that replace dependencies when testing.
I would argue that both cons outweigh the pros.

from minfraud-api-php.

oschwald avatar oschwald commented on August 25, 2024

I am a bit confused. Why can't you inject the object created by new MinFraud(...)? It is immutable and can be reused multiple times.

from minfraud-api-php.

Gamesh avatar Gamesh commented on August 25, 2024

never mind, didn't notice that it was $new->content that is being written to, miss-took it for $this->content as it was private

from minfraud-api-php.

Related Issues (20)

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.