1

What is the best practice in concatenating multiple strings? What I did is every concatenation will be on the next line? I'm following the psr-2 80 line limit and the 120 line soft limit.

e.g.

return (
    Config::get('url')['base_folder'] .
        Config::get('url')['user_image_folder'] .
            "/{$image_name}.jpg"
);

VS

return Config::get('url')['base_folder'] . Config::get('url')['user_image_folder'] . "/{$image_name}.jpg";
Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
Kevin Karl Leaño
  • 1,630
  • 3
  • 15
  • 20
  • 1
    I think there is no "right" answer to this. My opinion is that the first example is more readable (maybe loose the increasing indentation), and makes commiting changes to a VCS easier (diffs are clearer than if you made a change in the one-line version, i.e. where in the whole line is the change). – ishegg Feb 26 '18 at 04:24
  • 1
    This question does not belong on SO. It has nothing to do with a problem and is completely opinion based. I don't think it will even fit on code review. – Andreas Feb 26 '18 at 04:33

0 Answers0