[{"data":1,"prerenderedAt":3010},["ShallowReactive",2],{"post-cards":3,"categories":529,"post-solid-principles-in-php":567},[4,27,38,54,68,78,87,97,111,124,134,145,160,172,185,196,207,218,229,240,251,264,277,292,307,321,335,347,358,369,379,389,399,409,419,429,439,449,459,469,479,489,499,509,519],{"path":5,"title":6,"slug":7,"summary":8,"date":9,"readTime":10,"hasImage":11,"category":12,"tags":17,"tagSlugs":26},"\u002Fposts\u002Fgit-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow vs GitHub Flow: Choosing a Branching Strategy for Your Team","git-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow and GitHub Flow take very different approaches to team branching and releases. Let's compare them, see where trunk-based development fits, and sort out how to handle versioned releases, hotfixes, and everything in between.","2026-06-14",7,false,{"id":13,"name":14,"slug":15,"hue":16},4,"Git","git",158,[18,20,23],{"name":19,"slug":15},"GIT",{"name":21,"slug":22},"Workflow","workflow",{"name":24,"slug":25},"GitHub","github",[15,22,25],{"path":28,"title":29,"slug":30,"summary":31,"date":9,"readTime":10,"hasImage":11,"category":32,"tags":33,"tagSlugs":37},"\u002Fposts\u002Fgithub-flow-keep-your-main-branch-deployable","GitHub Flow: Keep Your Main Branch Deployable","github-flow-keep-your-main-branch-deployable","GitHub Flow is the lightweight branching workflow built on a single rule: anything in main is deployable. Here is the whole loop, branch, pull request, review, merge and deploy, with the git and gh commands and an honest look at where it fits.",{"id":13,"name":14,"slug":15,"hue":16},[34,35,36],{"name":19,"slug":15},{"name":21,"slug":22},{"name":24,"slug":25},[15,22,25],{"path":39,"title":40,"slug":41,"summary":42,"date":43,"readTime":44,"hasImage":11,"category":45,"tags":50,"tagSlugs":53},"\u002Fposts\u002Fstarting-with-rust-installation-first-program","Starting with Rust: From Installation to Your First Program","starting-with-rust-installation-first-program","Learn how to install Rust and write your first \"Hello, world!\" program.","2024-03-23",2,{"id":46,"name":47,"slug":48,"hue":49},6,"Rust","rust-programming",38,[51],{"name":52,"slug":52},"rust",[52],{"path":55,"title":56,"slug":57,"summary":58,"date":59,"readTime":44,"hasImage":11,"category":60,"tags":65,"tagSlugs":67},"\u002Fposts\u002Fflutter-version-management-fvm","Flutter Version Management","flutter-version-management-fvm","Managing multiple Flutter versions does not need not be a headache. Let's jump into FVM and see how it can simplify your Flutter journey.","2023-10-07",{"id":61,"name":62,"slug":63,"hue":64},5,"Flutter","flutter",230,[66],{"name":63,"slug":63},[63],{"path":69,"title":70,"slug":71,"summary":72,"date":59,"readTime":73,"hasImage":11,"category":74,"tags":75,"tagSlugs":77},"\u002Fposts\u002Fsetting-up-cocoapods-fvm","Setting Up CocoaPods for FVM-managed Flutter Projects","setting-up-cocoapods-fvm","A guide to installing CocoaPods for a Flutter project while using FVM to manage Flutter versions, ensuring a smooth setup for iOS development.",1,{"id":61,"name":62,"slug":63,"hue":64},[76],{"name":63,"slug":63},[63],{"path":79,"title":80,"slug":81,"summary":82,"date":59,"readTime":73,"hasImage":11,"category":83,"tags":84,"tagSlugs":86},"\u002Fposts\u002Ftroubleshooting-xcode-15-build-issues-flutter","Troubleshooting Xcode 15 Build Issues in Flutter Projects","troubleshooting-xcode-15-build-issues-flutter","Uncovering solutions to common issues faced when updating to Xcode 15 in a Flutter project using an older version of CocoaPods.",{"id":61,"name":62,"slug":63,"hue":64},[85],{"name":63,"slug":63},[63],{"path":88,"title":89,"slug":90,"summary":91,"date":92,"readTime":13,"hasImage":11,"category":93,"tags":94,"tagSlugs":96},"\u002Fposts\u002Fgit-tracking-a-remote-branch-upstream-for-changes","Git: Tracking a Remote Branch for Changes","git-tracking-a-remote-branch-upstream-for-changes","When you fork a project, you need a way to pull in changes from the original repository, usually called upstream. Here is how to wire up an upstream remote, actually sync your fork, and set up branch tracking so plain git pull and git push just work.","2018-11-04",{"id":13,"name":14,"slug":15,"hue":16},[95],{"name":19,"slug":15},[15],{"path":98,"title":99,"slug":100,"summary":101,"date":92,"readTime":102,"hasImage":103,"category":104,"tags":108,"tagSlugs":110},"\u002Fposts\u002Fjavascript-array-map-filter-reduce-functions","JavaScript's map, filter, and reduce methods","javascript-array-map-filter-reduce-functions","JavaScript provides some amazing functions that can be called against your arrays to help filter them, manipulate them, or even reduce them down to a single value or grouped values.",3,true,{"id":44,"name":105,"slug":106,"hue":107},"JavaScript","javascript",92,[109],{"name":105,"slug":106},[106],{"path":112,"title":113,"slug":114,"summary":115,"date":116,"readTime":73,"hasImage":103,"category":117,"tags":121,"tagSlugs":123},"\u002Fposts\u002Fphp-fizzbuzz-example","FizzBuzz in PHP: A Fresh Approach","php-fizzbuzz-example","FizzBuzz is a very popular programming question that tests your logic to see if you can build a simple program.","2018-11-02",{"id":73,"name":118,"slug":119,"hue":120},"PHP","php",264,[122],{"name":118,"slug":119},[119],{"path":125,"title":126,"slug":127,"summary":128,"date":129,"readTime":44,"hasImage":103,"category":130,"tags":131,"tagSlugs":133},"\u002Fposts\u002Fphp-array-reduce","PHP's array_reduce is not only for outputting single values","php-array-reduce","PHP's array_reduce is a simple way to partition a set of data or return a single value. It is super powerful and worth spending time learning.","2018-11-01",{"id":73,"name":118,"slug":119,"hue":120},[132],{"name":118,"slug":119},[119],{"path":135,"title":136,"slug":137,"summary":138,"date":139,"readTime":46,"hasImage":11,"category":140,"tags":141,"tagSlugs":144},"\u002Fposts\u002Fimprove-your-git-workflow-with-git-flow","Improve Your Git Workflow with Git Flow","improve-your-git-workflow-with-git-flow","Git Flow is a structured branching model built around versioned, scheduled releases. Here is how its branches fit together, a hands-on walkthrough of features, releases and hotfixes, and an honest take on when it is still the right call.","2016-12-06",{"id":13,"name":14,"slug":15,"hue":16},[142,143],{"name":19,"slug":15},{"name":21,"slug":22},[15,22],{"path":146,"title":147,"slug":148,"summary":149,"date":150,"readTime":46,"hasImage":11,"category":151,"tags":155,"tagSlugs":159},"\u002Fposts\u002Fusing-css-transitions","Using CSS Transitions","using-css-transitions","CSS transitions are the standard way to apply transitions to your elements, and have been for years, replacing the old approach of using JavaScript. In this article, I'll go through each of the transition properties available, and provide examples of how to use them.","2016-12-05",{"id":102,"name":152,"slug":153,"hue":154},"HTML & CSS","html-css",55,[156],{"name":157,"slug":158},"CSS","css",[158],{"path":161,"title":162,"slug":163,"summary":164,"date":165,"readTime":13,"hasImage":11,"category":166,"tags":167,"tagSlugs":171},"\u002Fposts\u002Fstructuring-your-website-with-html-5-semantics","Structuring Your Website With HTML 5 Semantics","structuring-your-website-with-html-5-semantics","Prior to HTML 5, there was no real markup to help explain the intent behind your HTML code. The goal of HTML 5 was to offer a more readable way of writing your code, so that any author that comes after you can have an easier time going through what you've created.","2016-12-04",{"id":102,"name":152,"slug":153,"hue":154},[168],{"name":169,"slug":170},"HTML","html",[170],{"path":173,"title":174,"slug":175,"summary":176,"date":177,"readTime":44,"hasImage":11,"category":178,"tags":179,"tagSlugs":184},"\u002Fposts\u002Finterpolation-in-stylus-css-pre-processor","Interpolation in Stylus","interpolation-in-stylus-css-pre-processor","You can also use interpolation to improve your functions for reuse, as well as your other code within your stylesheet. The way it works is that you can wrap your expression within {}, which will then be outputted as the identifier.","2016-12-03",{"id":102,"name":152,"slug":153,"hue":154},[180,183],{"name":181,"slug":182},"Stylus","stylus",{"name":157,"slug":158},[182,158],{"path":186,"title":187,"slug":188,"summary":189,"date":190,"readTime":73,"hasImage":11,"category":191,"tags":192,"tagSlugs":195},"\u002Fposts\u002Fcreating-configuration-files-in-stylus-css-pre-processor","Creating Configuration Files In Stylus","creating-configuration-files-in-stylus-css-pre-processor","It's super simple to create a configuration file for instance that would manage your media query break points. You could also use a configuration file for managing colors, font sizes, and other variables such as gutter spacing and more.","2016-12-02",{"id":102,"name":152,"slug":153,"hue":154},[193,194],{"name":157,"slug":158},{"name":181,"slug":182},[158,182],{"path":197,"title":198,"slug":199,"summary":200,"date":201,"readTime":13,"hasImage":11,"category":202,"tags":203,"tagSlugs":206},"\u002Fposts\u002Fusing-functions-and-mixins-with-stylus-css-pre-processor","Using Functions and Mixins with Stylus","using-functions-and-mixins-with-stylus-css-pre-processor","Stylus allows you to create functions and mixins of reusable code for your stylesheets. You can also handle mathematical operations, unary operations, and more allowing you complete control over your stylesheets with ease.","2016-12-01",{"id":102,"name":152,"slug":153,"hue":154},[204,205],{"name":157,"slug":158},{"name":181,"slug":182},[158,182],{"path":208,"title":209,"slug":210,"summary":211,"date":212,"readTime":44,"hasImage":11,"category":213,"tags":214,"tagSlugs":217},"\u002Fposts\u002Fsetting-variables-in-stylus-css-pre-processor","Setting Variables in Stylus","setting-variables-in-stylus-css-pre-processor","Unlike CSS, in Stylus you can assign expressions to variables that can be reusable throughout your stylesheets.","2016-11-29",{"id":102,"name":152,"slug":153,"hue":154},[215,216],{"name":157,"slug":158},{"name":181,"slug":182},[158,182],{"path":219,"title":220,"slug":221,"summary":222,"date":223,"readTime":61,"hasImage":11,"category":224,"tags":225,"tagSlugs":228},"\u002Fposts\u002Fusing-selectors-in-stylus-css-pre-processor","Using Selectors in Stylus","using-selectors-in-stylus-css-pre-processor","Selectors are a way to pick the elements that you want styled. In Stylus, similar to CSS, you can apply a set of styles to any element by separating them by a comma delimited list. Stylus though, also allows you to select multiple elements by separating each on their own line.","2016-11-28",{"id":102,"name":152,"slug":153,"hue":154},[226,227],{"name":157,"slug":158},{"name":181,"slug":182},[158,182],{"path":230,"title":231,"slug":232,"summary":233,"date":234,"readTime":73,"hasImage":11,"category":235,"tags":236,"tagSlugs":239},"\u002Fposts\u002Flearning-stylus-a-css-pre-processor","Learning Stylus: A CSS Pre-Processor","learning-stylus-a-css-pre-processor","This mini-series will be a little different to how you may see other articles on my site. Really this article is more geared as notes for me as I go through the documentation for Stylus, and learn the ins and outs of this beautiful language.","2016-11-27",{"id":102,"name":152,"slug":153,"hue":154},[237,238],{"name":157,"slug":158},{"name":181,"slug":182},[158,182],{"path":241,"title":242,"slug":243,"summary":244,"date":245,"readTime":13,"hasImage":11,"category":246,"tags":247,"tagSlugs":250},"\u002Fposts\u002Fbem-methodology-overview-and-naming-conventions","BEM Methodology Overview and Naming Conventions","bem-methodology-overview-and-naming-conventions","BEM or Block Element Modifier is a naming convention used to help organize your code base. In this article, I discuss its uses within your CSS projects.","2016-11-26",{"id":102,"name":152,"slug":153,"hue":154},[248,249],{"name":157,"slug":158},{"name":169,"slug":170},[158,170],{"path":252,"title":253,"slug":254,"summary":255,"date":256,"readTime":73,"hasImage":11,"category":257,"tags":258,"tagSlugs":263},"\u002Fposts\u002Fintroduction-to-ecmascript-6","Introduction to ECMAScript 6","introduction-to-ecmascript-6","The latest in ECMAScript 6 introduces new features to JavaScript which makes it so much more fun to use, while solving problems that have been around for years. The intent of this article is to provide you with resources you can use to start learning ES6 today.","2016-11-25",{"id":44,"name":105,"slug":106,"hue":107},[259,260],{"name":105,"slug":106},{"name":261,"slug":262},"ECMAScript","ecmascript",[106,262],{"path":265,"title":266,"slug":267,"summary":268,"date":269,"readTime":102,"hasImage":11,"category":270,"tags":271,"tagSlugs":276},"\u002Fposts\u002Fbabel-installation-and-configuration","Babel Installation and Configuration","babel-installation-and-configuration","Babel offers a convenient way to transform your ES6 code to JavaScript that all browsers can understand. In this article we'll go over a basic configuration that will enable you to start using it with any project right away.","2016-11-24",{"id":44,"name":105,"slug":106,"hue":107},[272,273],{"name":105,"slug":106},{"name":274,"slug":275},"Babel","babel",[106,275],{"path":278,"title":279,"slug":280,"summary":281,"date":282,"readTime":73,"hasImage":11,"category":283,"tags":284,"tagSlugs":291},"\u002Fposts\u002Fconfiguring-stylus-css-pre-processor-with-gulp-and-sourcemaps","Configuring Stylus CSS Pre-Processor with Gulp and Sourcemaps","configuring-stylus-css-pre-processor-with-gulp-and-sourcemaps","In this article we'll go over how to configure your project to process Stylus files using Gulp. We'll also create source map file which your browser will use to help point you in the right direction of your files when developing","2016-11-23",{"id":44,"name":105,"slug":106,"hue":107},[285,286,287,288],{"name":105,"slug":106},{"name":181,"slug":182},{"name":157,"slug":158},{"name":289,"slug":290},"Gulp","gulp",[106,182,158,290],{"path":293,"title":294,"slug":295,"summary":296,"date":297,"readTime":44,"hasImage":11,"category":298,"tags":299,"tagSlugs":306},"\u002Fposts\u002Fconfiguring-gulp-with-less-css-pre-processor","Configuring Gulp With Less CSS Pre-Processor","configuring-gulp-with-less-css-pre-processor","Less is a CSS pre-processor allowing you to create variables, mixins, and functions in an effort to make your CSS more maintainable.","2016-11-22",{"id":44,"name":105,"slug":106,"hue":107},[300,301,302,305],{"name":289,"slug":290},{"name":105,"slug":106},{"name":303,"slug":304},"Less","less",{"name":157,"slug":158},[290,106,304,158],{"path":308,"title":309,"slug":310,"summary":311,"date":312,"readTime":44,"hasImage":103,"category":313,"tags":314,"tagSlugs":320},"\u002Fposts\u002Fusing-browser-sync-with-gulp-for-live-reloading","Using Browser Sync with Gulp for Live Reloading","using-browser-sync-with-gulp-for-live-reloading","Browser Sync is a nice tool to use while developing. It allows your browser to reload live when changes are made to your files. For instance, assuming we're watching our CSS file for changes we can have the browser auto refresh\u002Fsync when it sees those changes made.","2016-11-21",{"id":44,"name":105,"slug":106,"hue":107},[315,316,319],{"name":105,"slug":106},{"name":317,"slug":318},"Browser Sync","browser-sync",{"name":289,"slug":290},[106,318,290],{"path":322,"title":323,"slug":324,"summary":325,"date":326,"readTime":44,"hasImage":11,"category":327,"tags":328,"tagSlugs":334},"\u002Fposts\u002Fgulp-watch-automate-your-gulp-tasks","Gulp Watch: Automate Your Gulp Tasks","gulp-watch-automate-your-gulp-tasks","Gulp watch is perfect for when you're editing project files since it allows you to not have to run the gulp command manually each time.","2016-11-20",{"id":44,"name":105,"slug":106,"hue":107},[329,330,333],{"name":105,"slug":106},{"name":331,"slug":332},"Yarn","yarn",{"name":289,"slug":290},[106,332,290],{"path":336,"title":337,"slug":338,"summary":339,"date":340,"readTime":46,"hasImage":11,"category":341,"tags":342,"tagSlugs":346},"\u002Fposts\u002Fconfiguring-gulp-on-a-new-project","Configuring Gulp On A New Project","configuring-gulp-on-a-new-project","Gulp may seem like a scary thing to wrap your head around at first, but it's actually quite easy to start using once you understand the basics.","2016-11-19",{"id":44,"name":105,"slug":106,"hue":107},[343,344,345],{"name":105,"slug":106},{"name":289,"slug":290},{"name":331,"slug":332},[106,290,332],{"path":348,"title":349,"slug":350,"summary":351,"date":352,"readTime":102,"hasImage":11,"category":353,"tags":354,"tagSlugs":357},"\u002Fposts\u002Fyarn-publishing-a-package","Yarn: Publishing a Package","yarn-publishing-a-package","Publishing a package to the npm repository has never been simpler. With a few steps, you can create a package that is redistributable to all of your projects.","2016-11-18",{"id":44,"name":105,"slug":106,"hue":107},[355,356],{"name":105,"slug":106},{"name":331,"slug":332},[106,332],{"path":359,"title":360,"slug":361,"summary":362,"date":363,"readTime":102,"hasImage":11,"category":364,"tags":365,"tagSlugs":368},"\u002Fposts\u002Fyarn-fast-and-secure-dependency-management","Yarn: Fast and Secure Dependency Management","yarn-fast-and-secure-dependency-management","Yarn is a super simple dependency management tool which is way faster to use instead of traditional npm. It acts as a drop-in replacement, so you can get started using yarn right away. The best way to install yarn is by using npm.","2016-11-17",{"id":44,"name":105,"slug":106,"hue":107},[366,367],{"name":105,"slug":106},{"name":331,"slug":332},[106,332],{"path":370,"title":371,"slug":372,"summary":373,"date":374,"readTime":73,"hasImage":103,"category":375,"tags":376,"tagSlugs":378},"\u002Fposts\u002Fsupport-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Support for keys in list(), or its new shorthand syntax [] in PHP","support-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Now as of PHP 7.1, you can define the keys of your array that will be parsed when destructuring your arrays. Prior to PHP 7.1, you could only use arrays with numeric indexes. Now with this new addition, our lives just got easier.","2016-11-16",{"id":73,"name":118,"slug":119,"hue":120},[377],{"name":118,"slug":119},[119],{"path":380,"title":381,"slug":382,"summary":383,"date":384,"readTime":73,"hasImage":103,"category":385,"tags":386,"tagSlugs":388},"\u002Fposts\u002Ftype-hinting-with-the-iterable-pseudo-type-in-php","Type Hinting With The Iterable pseudo-type In PHP","type-hinting-with-the-iterable-pseudo-type-in-php","As of PHP 7.1, you can now type hint your method\u002Ffunction arguments with the keyword iterable for handling arrays or even objects that implement the Traversable interface.","2016-11-15",{"id":73,"name":118,"slug":119,"hue":120},[387],{"name":118,"slug":119},[119],{"path":390,"title":391,"slug":392,"summary":393,"date":394,"readTime":73,"hasImage":103,"category":395,"tags":396,"tagSlugs":398},"\u002Fposts\u002Ftype-hinting-callable-functions-in-php","Type Hinting Callable Functions in PHP","type-hinting-callable-functions-in-php","As of PHP 5.4, you can type hint your method arguments with the callable keyword allowing you to enforce the type of data that is passed via your arguments.","2016-11-14",{"id":73,"name":118,"slug":119,"hue":120},[397],{"name":118,"slug":119},[119],{"path":400,"title":401,"slug":402,"summary":403,"date":404,"readTime":73,"hasImage":103,"category":405,"tags":406,"tagSlugs":408},"\u002Fposts\u002Fsetting-visibility-for-your-class-constants-in-php","Setting Visibility for Your Class Constants in PHP","setting-visibility-for-your-class-constants-in-php","Now in PHP 7.1+, you can set different visibility modifiers for each of your class constants. The available visibility modifiers consist of public, protected, and private.","2016-11-13",{"id":73,"name":118,"slug":119,"hue":120},[407],{"name":118,"slug":119},[119],{"path":410,"title":411,"slug":412,"summary":413,"date":414,"readTime":73,"hasImage":103,"category":415,"tags":416,"tagSlugs":418},"\u002Fposts\u002Fanonymous-classes-php","Using Anonymous Classes in PHP","anonymous-classes-php","As of PHP 7, you can now create quick throwaway objects for use within your projects. This can be especially useful for your automated tests, for instance, with allowing you to create quick implementations of your interfaces.","2016-11-12",{"id":73,"name":118,"slug":119,"hue":120},[417],{"name":118,"slug":119},[119],{"path":420,"title":421,"slug":422,"summary":423,"date":424,"readTime":73,"hasImage":103,"category":425,"tags":426,"tagSlugs":428},"\u002Fposts\u002Fsymmetric-array-destructuring-in-php","Symmetric Array Destructuring in PHP","symmetric-array-destructuring-in-php","As of PHP 7.1, you can now use the shorthand array syntax to destructure your arrays for assignment. Previously you would have had to use a function like list, but now you can use the simple new array shorthand syntax.","2016-11-11",{"id":73,"name":118,"slug":119,"hue":120},[427],{"name":118,"slug":119},[119],{"path":430,"title":431,"slug":432,"summary":433,"date":434,"readTime":44,"hasImage":103,"category":435,"tags":436,"tagSlugs":438},"\u002Fposts\u002Fphp-array-map-to-format-your-arrays-without-loops","Using PHP's array_map to format your arrays without loops","php-array-map-to-format-your-arrays-without-loops","So let's face it, loops are a bit boring. So how can we mix it up? Let's assume we have a case where we have a CSV file that we want to quickly parse.","2016-11-10",{"id":73,"name":118,"slug":119,"hue":120},[437],{"name":118,"slug":119},[119],{"path":440,"title":441,"slug":442,"summary":443,"date":444,"readTime":10,"hasImage":103,"category":445,"tags":446,"tagSlugs":448},"\u002Fposts\u002Fsolid-principles-in-php","SOLID Principles in PHP","solid-principles-in-php","The 5 basic principles for Object-Oriented Design, SOLID, were first created in an effort to improve maintainability in our code bases. SOLID is a mnemonic acronym that stands for each of the following principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.","2016-11-09",{"id":73,"name":118,"slug":119,"hue":120},[447],{"name":118,"slug":119},[119],{"path":450,"title":451,"slug":452,"summary":453,"date":454,"readTime":73,"hasImage":103,"category":455,"tags":456,"tagSlugs":458},"\u002Fposts\u002Ffiltering-arrays-without-using-loops-in-php","Filtering Arrays Without Using Loops in PHP","filtering-arrays-without-using-loops-in-php","PHP has a built-in function called array_filter that allows you to filter through your arrays without the need for a loop. Personally, this approach feels much cleaner to me and simpler to comprehend.","2016-11-08",{"id":73,"name":118,"slug":119,"hue":120},[457],{"name":118,"slug":119},[119],{"path":460,"title":461,"slug":462,"summary":463,"date":464,"readTime":73,"hasImage":103,"category":465,"tags":466,"tagSlugs":468},"\u002Fposts\u002Fvoid-return-types-in-php","Void Return Types in PHP","void-return-types-in-php","As of PHP 7.1, we can now use void return types within our methods. This is useful for cases where you have methods that are just setting or processing data without the need of returning any values.","2016-11-07",{"id":73,"name":118,"slug":119,"hue":120},[467],{"name":118,"slug":119},[119],{"path":470,"title":471,"slug":472,"summary":473,"date":474,"readTime":73,"hasImage":103,"category":475,"tags":476,"tagSlugs":478},"\u002Fposts\u002Ftype-hinting-with-nullable-types-in-php","Type Hinting with Nullable Types in PHP","type-hinting-with-nullable-types-in-php","As of PHP 7.1, you can now set your type declarations as nullable by simply prefixing them with a question mark ?. In doing so a null value can be passed in as a parameter or returned as a value for your methods.","2016-11-06",{"id":73,"name":118,"slug":119,"hue":120},[477],{"name":118,"slug":119},[119],{"path":480,"title":481,"slug":482,"summary":483,"date":484,"readTime":73,"hasImage":103,"category":485,"tags":486,"tagSlugs":488},"\u002Fposts\u002Fphp-group-multiple-use-declarations","PHP Group Multiple use Declarations","php-group-multiple-use-declarations","As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace.","2016-11-05",{"id":73,"name":118,"slug":119,"hue":120},[487],{"name":118,"slug":119},[119],{"path":490,"title":491,"slug":492,"summary":493,"date":494,"readTime":73,"hasImage":103,"category":495,"tags":496,"tagSlugs":498},"\u002Fposts\u002Fphp-null-coalescing-operator","PHP Null Coalescing Operator","php-null-coalescing-operator","One of my new favorite additions to PHP 7, is the Null Coalescing Operator. It cleans up your code by removing a tedious step of checking if some value is isset() and not NULL and returning it or if not setting a default.","2016-11-04",{"id":73,"name":118,"slug":119,"hue":120},[497],{"name":118,"slug":119},[119],{"path":500,"title":501,"slug":502,"summary":503,"date":504,"readTime":44,"hasImage":103,"category":505,"tags":506,"tagSlugs":508},"\u002Fposts\u002Fphp-spaceship-operator","PHP Spaceship Operator","php-spaceship-operator","One of the new features to hit PHP 7 is the Spaceship Operator. This new trick helps improve the way you'd compare 2 expressions. In short, the comparison returns 1 of 3 values (-1, 0, or 1) depending on the result of the comparison.","2016-11-03",{"id":73,"name":118,"slug":119,"hue":120},[507],{"name":118,"slug":119},[119],{"path":510,"title":511,"slug":512,"summary":513,"date":514,"readTime":102,"hasImage":103,"category":515,"tags":516,"tagSlugs":518},"\u002Fposts\u002Freturn-type-declarations-in-php","Return Type Declarations in PHP","return-type-declarations-in-php","PHP 7 now makes it possible to declare return types for your methods. This allows you better control over the data that will be returned from each method in your application.","2016-11-02",{"id":73,"name":118,"slug":119,"hue":120},[517],{"name":118,"slug":119},[119],{"path":520,"title":521,"slug":522,"summary":523,"date":524,"readTime":73,"hasImage":103,"category":525,"tags":526,"tagSlugs":528},"\u002Fposts\u002Fscalar-type-hints-php","Scalar Type Hints in PHP","scalar-type-hints-php","Starting with PHP 7.0, it's now possible to declare scalar type hints for your method arguments. Previously, we were able to use array and callable, but now with PHP 7+, we have much more control.","2016-11-01",{"id":73,"name":118,"slug":119,"hue":120},[527],{"name":118,"slug":119},[119],[530,537,543,549,555,561],{"id":531,"description":532,"extension":533,"hue":120,"meta":534,"name":118,"slug":119,"stem":535,"weight":73,"__hash__":536},"categories\u002Fcategories\u002Fphp.json","PHP articles and tutorials ranging from new language features to using interesting packages.","json",{},"categories\u002Fphp","h_EmN4YMO4b2mBt3MPLs7RvscJx0NBmwDIZPxqPqKLE",{"id":538,"description":539,"extension":533,"hue":107,"meta":540,"name":105,"slug":106,"stem":541,"weight":44,"__hash__":542},"categories\u002Fcategories\u002Fjavascript.json","JavaScript articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fjavascript","7gmVgkw5BRo26i1bFoSv96bwDJ4nTtZcJ9Ud6u5p0yk",{"id":544,"description":545,"extension":533,"hue":154,"meta":546,"name":152,"slug":153,"stem":547,"weight":102,"__hash__":548},"categories\u002Fcategories\u002Fhtml-css.json","HTML & CSS articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fhtml-css","vXvPlRA-iaeCJ64Wi3sLyUR0kqL48zYcZWORRqt8N70",{"id":550,"description":551,"extension":533,"hue":16,"meta":552,"name":14,"slug":15,"stem":553,"weight":13,"__hash__":554},"categories\u002Fcategories\u002Fgit.json","Git articles and tutorials ranging from new language features to different workflows.",{},"categories\u002Fgit","qOqFsFTKI9XB444UodUKW_3AakFadHzW-ss8V-maUmE",{"id":556,"description":557,"extension":533,"hue":64,"meta":558,"name":62,"slug":63,"stem":559,"weight":61,"__hash__":560},"categories\u002Fcategories\u002Fflutter.json","Dive into Flutter, the open-source UI software development toolkit, as we explore its capabilities in creating natively compiled applications for mobile, web, and desktop from a single codebase.",{},"categories\u002Fflutter","aD1moU8CgoYt4FRnSeA4Iy9xxnnopdEKBEYP2arAzdI",{"id":562,"description":563,"extension":533,"hue":49,"meta":564,"name":47,"slug":48,"stem":565,"weight":46,"__hash__":566},"categories\u002Fcategories\u002Frust-programming.json","From setting up your environment to advanced concepts, this is your go-to resource for all things Rust.",{},"categories\u002Frust-programming","LscnqSsk-htWc9yZg9eXaIUJwNfTK5oaZOClYKagNC4",{"id":568,"title":441,"body":569,"category":3001,"date":444,"description":575,"extension":3002,"hasImage":103,"meta":3003,"navigation":103,"path":440,"readTime":10,"seo":3004,"slug":442,"stem":3005,"summary":443,"tagSlugs":3006,"tags":3007,"__hash__":3009},"posts\u002Fposts\u002Fsolid-principles-in-php.md",{"type":570,"value":571,"toc":2993},"minimark",[572,576,579,599,604,607,610,821,824,827,1178,1181,1286,1290,1293,1296,1299,1302,1305,1726,1729,1732,1840,1843,1847,1850,1853,2305,2308,2440,2443,2447,2450,2453,2456,2459,2722,2726,2729,2732,2859,2862,2865,2979,2983,2986,2989],[573,574,575],"p",{},"The 5 basic principles for Object Oriented Design, SOLID, were first created in an effort to improve maintainability in our code bases. SOLID is a mnemonic acronym that stands for each of the following principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.",[573,577,578],{},"In this article, I'll explain in short what each principle is about. I will also include an example use case for each to portray what these principles hope to accomplish.",[580,581,583],"note",{"label":582},"From 2026",[573,584,585,586,590,591,594,595,598],{},"SOLID is language-agnostic and just as relevant today. Modern PHP (8.x) makes some of this easier with first-class ",[587,588,589],"code",{},"interface",", ",[587,592,593],{},"readonly"," properties, ",[587,596,597],{},"enum",", and constructor property promotion.",[600,601,603],"h2",{"id":602},"single-responsibility-principle-srp","Single Responsibility Principle (SRP)",[573,605,606],{},"This principle states that each class should only have a single responsibility and only one reason to change within an application.",[573,608,609],{},"Let's look at an example of some code that does not really follow this principle.",[611,612,616],"pre",{"className":613,"code":614,"language":119,"meta":615,"style":615},"language-php shiki shiki-themes github-dark github-dark","\u003C?php\n\nclass Notification\n{\n    private $message;\n\n    public function __construct($message)\n    {\n        $this->message = $message;\n    }\n\n    public function message()\n    {\n        return $this->message;\n    }\n\n    public function sendToEmail($email)\n    {\n        \u002F\u002F Code Here\n    }\n\n    public function sendToSMS($mobileNumber)\n    {\n        \u002F\u002F Code Here\n    }\n}\n","",[587,617,618,630,635,644,650,658,662,676,682,699,705,710,723,728,742,747,752,765,770,777,782,787,800,805,810,815],{"__ignoreMap":615},[619,620,622,626],"span",{"class":621,"line":73},"line",[619,623,625],{"class":624},"sOPea","\u003C?",[619,627,629],{"class":628},"s8ozJ","php\n",[619,631,632],{"class":621,"line":44},[619,633,634],{"emptyLinePlaceholder":103},"\n",[619,636,637,640],{"class":621,"line":102},[619,638,639],{"class":624},"class",[619,641,643],{"class":642},"sFR8T"," Notification\n",[619,645,646],{"class":621,"line":13},[619,647,649],{"class":648},"suv1-","{\n",[619,651,652,655],{"class":621,"line":61},[619,653,654],{"class":624},"    private",[619,656,657],{"class":648}," $message;\n",[619,659,660],{"class":621,"line":46},[619,661,634],{"emptyLinePlaceholder":103},[619,663,664,667,670,673],{"class":621,"line":10},[619,665,666],{"class":624},"    public",[619,668,669],{"class":624}," function",[619,671,672],{"class":628}," __construct",[619,674,675],{"class":648},"($message)\n",[619,677,679],{"class":621,"line":678},8,[619,680,681],{"class":648},"    {\n",[619,683,685,688,691,694,697],{"class":621,"line":684},9,[619,686,687],{"class":628},"        $this",[619,689,690],{"class":624},"->",[619,692,693],{"class":648},"message ",[619,695,696],{"class":624},"=",[619,698,657],{"class":648},[619,700,702],{"class":621,"line":701},10,[619,703,704],{"class":648},"    }\n",[619,706,708],{"class":621,"line":707},11,[619,709,634],{"emptyLinePlaceholder":103},[619,711,713,715,717,720],{"class":621,"line":712},12,[619,714,666],{"class":624},[619,716,669],{"class":624},[619,718,719],{"class":642}," message",[619,721,722],{"class":648},"()\n",[619,724,726],{"class":621,"line":725},13,[619,727,681],{"class":648},[619,729,731,734,737,739],{"class":621,"line":730},14,[619,732,733],{"class":624},"        return",[619,735,736],{"class":628}," $this",[619,738,690],{"class":624},[619,740,741],{"class":648},"message;\n",[619,743,745],{"class":621,"line":744},15,[619,746,704],{"class":648},[619,748,750],{"class":621,"line":749},16,[619,751,634],{"emptyLinePlaceholder":103},[619,753,755,757,759,762],{"class":621,"line":754},17,[619,756,666],{"class":624},[619,758,669],{"class":624},[619,760,761],{"class":642}," sendToEmail",[619,763,764],{"class":648},"($email)\n",[619,766,768],{"class":621,"line":767},18,[619,769,681],{"class":648},[619,771,773],{"class":621,"line":772},19,[619,774,776],{"class":775},"sJ8bj","        \u002F\u002F Code Here\n",[619,778,780],{"class":621,"line":779},20,[619,781,704],{"class":648},[619,783,785],{"class":621,"line":784},21,[619,786,634],{"emptyLinePlaceholder":103},[619,788,790,792,794,797],{"class":621,"line":789},22,[619,791,666],{"class":624},[619,793,669],{"class":624},[619,795,796],{"class":642}," sendToSMS",[619,798,799],{"class":648},"($mobileNumber)\n",[619,801,803],{"class":621,"line":802},23,[619,804,681],{"class":648},[619,806,808],{"class":621,"line":807},24,[619,809,776],{"class":775},[619,811,813],{"class":621,"line":812},25,[619,814,704],{"class":648},[619,816,818],{"class":621,"line":817},26,[619,819,820],{"class":648},"}\n",[573,822,823],{},"The problem above is that not only are you creating the Notification message here, you're also expecting the same class to know how to send it to an Email or SMS. We should separate this business logic from the presentation data.",[573,825,826],{},"Now we'll see how we can update it to better follow the Single Responsibility Principle.",[611,828,830],{"className":613,"code":829,"language":119,"meta":615,"style":615},"\u003C?php\n\nclass Notification\n{\n    private $message;\n\n    public function __construct($message)\n    {\n        $this->message = $message;\n    }\n\n    public function message()\n    {\n        return $this->message;\n    }\n}\n\ninterface Notifier\n{\n    public function send($to);\n}\n\nclass EmailNotifier implements Notifier\n{\n    private $notification;\n\n    public function __construct(Notification $notification)\n    {\n        $this->notification = $notification;\n    }\n\n    public function send($to)\n    {\n        \u002F\u002F Email Logic Here\n    }\n}\n\nclass SMSNotifier implements Notifier\n{\n    private $notification;\n\n    public function __construct(Notification $notification)\n    {\n        $this->notification = $notification;\n    }\n\n    public function send($to)\n    {\n        \u002F\u002F SMS Logic Here\n    }\n}\n",[587,831,832,838,842,848,852,858,862,872,876,888,892,896,906,910,920,924,928,932,939,943,955,959,963,975,979,986,990,1008,1013,1027,1032,1037,1049,1054,1060,1065,1070,1075,1086,1091,1098,1103,1118,1123,1136,1141,1146,1157,1162,1168,1173],{"__ignoreMap":615},[619,833,834,836],{"class":621,"line":73},[619,835,625],{"class":624},[619,837,629],{"class":628},[619,839,840],{"class":621,"line":44},[619,841,634],{"emptyLinePlaceholder":103},[619,843,844,846],{"class":621,"line":102},[619,845,639],{"class":624},[619,847,643],{"class":642},[619,849,850],{"class":621,"line":13},[619,851,649],{"class":648},[619,853,854,856],{"class":621,"line":61},[619,855,654],{"class":624},[619,857,657],{"class":648},[619,859,860],{"class":621,"line":46},[619,861,634],{"emptyLinePlaceholder":103},[619,863,864,866,868,870],{"class":621,"line":10},[619,865,666],{"class":624},[619,867,669],{"class":624},[619,869,672],{"class":628},[619,871,675],{"class":648},[619,873,874],{"class":621,"line":678},[619,875,681],{"class":648},[619,877,878,880,882,884,886],{"class":621,"line":684},[619,879,687],{"class":628},[619,881,690],{"class":624},[619,883,693],{"class":648},[619,885,696],{"class":624},[619,887,657],{"class":648},[619,889,890],{"class":621,"line":701},[619,891,704],{"class":648},[619,893,894],{"class":621,"line":707},[619,895,634],{"emptyLinePlaceholder":103},[619,897,898,900,902,904],{"class":621,"line":712},[619,899,666],{"class":624},[619,901,669],{"class":624},[619,903,719],{"class":642},[619,905,722],{"class":648},[619,907,908],{"class":621,"line":725},[619,909,681],{"class":648},[619,911,912,914,916,918],{"class":621,"line":730},[619,913,733],{"class":624},[619,915,736],{"class":628},[619,917,690],{"class":624},[619,919,741],{"class":648},[619,921,922],{"class":621,"line":744},[619,923,704],{"class":648},[619,925,926],{"class":621,"line":749},[619,927,820],{"class":648},[619,929,930],{"class":621,"line":754},[619,931,634],{"emptyLinePlaceholder":103},[619,933,934,936],{"class":621,"line":767},[619,935,589],{"class":624},[619,937,938],{"class":642}," Notifier\n",[619,940,941],{"class":621,"line":772},[619,942,649],{"class":648},[619,944,945,947,949,952],{"class":621,"line":779},[619,946,666],{"class":624},[619,948,669],{"class":624},[619,950,951],{"class":642}," send",[619,953,954],{"class":648},"($to);\n",[619,956,957],{"class":621,"line":784},[619,958,820],{"class":648},[619,960,961],{"class":621,"line":789},[619,962,634],{"emptyLinePlaceholder":103},[619,964,965,967,970,973],{"class":621,"line":802},[619,966,639],{"class":624},[619,968,969],{"class":642}," EmailNotifier",[619,971,972],{"class":624}," implements",[619,974,938],{"class":642},[619,976,977],{"class":621,"line":807},[619,978,649],{"class":648},[619,980,981,983],{"class":621,"line":812},[619,982,654],{"class":624},[619,984,985],{"class":648}," $notification;\n",[619,987,988],{"class":621,"line":817},[619,989,634],{"emptyLinePlaceholder":103},[619,991,993,995,997,999,1002,1005],{"class":621,"line":992},27,[619,994,666],{"class":624},[619,996,669],{"class":624},[619,998,672],{"class":628},[619,1000,1001],{"class":648},"(",[619,1003,1004],{"class":628},"Notification",[619,1006,1007],{"class":648}," $notification)\n",[619,1009,1011],{"class":621,"line":1010},28,[619,1012,681],{"class":648},[619,1014,1016,1018,1020,1023,1025],{"class":621,"line":1015},29,[619,1017,687],{"class":628},[619,1019,690],{"class":624},[619,1021,1022],{"class":648},"notification ",[619,1024,696],{"class":624},[619,1026,985],{"class":648},[619,1028,1030],{"class":621,"line":1029},30,[619,1031,704],{"class":648},[619,1033,1035],{"class":621,"line":1034},31,[619,1036,634],{"emptyLinePlaceholder":103},[619,1038,1040,1042,1044,1046],{"class":621,"line":1039},32,[619,1041,666],{"class":624},[619,1043,669],{"class":624},[619,1045,951],{"class":642},[619,1047,1048],{"class":648},"($to)\n",[619,1050,1052],{"class":621,"line":1051},33,[619,1053,681],{"class":648},[619,1055,1057],{"class":621,"line":1056},34,[619,1058,1059],{"class":775},"        \u002F\u002F Email Logic Here\n",[619,1061,1063],{"class":621,"line":1062},35,[619,1064,704],{"class":648},[619,1066,1068],{"class":621,"line":1067},36,[619,1069,820],{"class":648},[619,1071,1073],{"class":621,"line":1072},37,[619,1074,634],{"emptyLinePlaceholder":103},[619,1076,1077,1079,1082,1084],{"class":621,"line":49},[619,1078,639],{"class":624},[619,1080,1081],{"class":642}," SMSNotifier",[619,1083,972],{"class":624},[619,1085,938],{"class":642},[619,1087,1089],{"class":621,"line":1088},39,[619,1090,649],{"class":648},[619,1092,1094,1096],{"class":621,"line":1093},40,[619,1095,654],{"class":624},[619,1097,985],{"class":648},[619,1099,1101],{"class":621,"line":1100},41,[619,1102,634],{"emptyLinePlaceholder":103},[619,1104,1106,1108,1110,1112,1114,1116],{"class":621,"line":1105},42,[619,1107,666],{"class":624},[619,1109,669],{"class":624},[619,1111,672],{"class":628},[619,1113,1001],{"class":648},[619,1115,1004],{"class":628},[619,1117,1007],{"class":648},[619,1119,1121],{"class":621,"line":1120},43,[619,1122,681],{"class":648},[619,1124,1126,1128,1130,1132,1134],{"class":621,"line":1125},44,[619,1127,687],{"class":628},[619,1129,690],{"class":624},[619,1131,1022],{"class":648},[619,1133,696],{"class":624},[619,1135,985],{"class":648},[619,1137,1139],{"class":621,"line":1138},45,[619,1140,704],{"class":648},[619,1142,1144],{"class":621,"line":1143},46,[619,1145,634],{"emptyLinePlaceholder":103},[619,1147,1149,1151,1153,1155],{"class":621,"line":1148},47,[619,1150,666],{"class":624},[619,1152,669],{"class":624},[619,1154,951],{"class":642},[619,1156,1048],{"class":648},[619,1158,1160],{"class":621,"line":1159},48,[619,1161,681],{"class":648},[619,1163,1165],{"class":621,"line":1164},49,[619,1166,1167],{"class":775},"        \u002F\u002F SMS Logic Here\n",[619,1169,1171],{"class":621,"line":1170},50,[619,1172,704],{"class":648},[619,1174,1176],{"class":621,"line":1175},51,[619,1177,820],{"class":648},[573,1179,1180],{},"Now that we've organized the above in this fashion, it is easy for us to create new Notifiers without having to ever touch any of the existing classes. For instance, let's assume we want to create a notifier capable of sending notifications to Slack. We could simply create a new class for this like so.",[611,1182,1184],{"className":613,"code":1183,"language":119,"meta":615,"style":615},"\u003C?php\n\nclass SlackNotifier implements Notifier\n{\n    private $notification;\n\n    public function __construct(Notification $notification)\n    {\n        $this->notification = $notification;\n    }\n\n    public function send($to)\n    {\n        \u002F\u002F Slack Logic Here\n    }\n}\n",[587,1185,1186,1192,1196,1207,1211,1217,1221,1235,1239,1251,1255,1259,1269,1273,1278,1282],{"__ignoreMap":615},[619,1187,1188,1190],{"class":621,"line":73},[619,1189,625],{"class":624},[619,1191,629],{"class":628},[619,1193,1194],{"class":621,"line":44},[619,1195,634],{"emptyLinePlaceholder":103},[619,1197,1198,1200,1203,1205],{"class":621,"line":102},[619,1199,639],{"class":624},[619,1201,1202],{"class":642}," SlackNotifier",[619,1204,972],{"class":624},[619,1206,938],{"class":642},[619,1208,1209],{"class":621,"line":13},[619,1210,649],{"class":648},[619,1212,1213,1215],{"class":621,"line":61},[619,1214,654],{"class":624},[619,1216,985],{"class":648},[619,1218,1219],{"class":621,"line":46},[619,1220,634],{"emptyLinePlaceholder":103},[619,1222,1223,1225,1227,1229,1231,1233],{"class":621,"line":10},[619,1224,666],{"class":624},[619,1226,669],{"class":624},[619,1228,672],{"class":628},[619,1230,1001],{"class":648},[619,1232,1004],{"class":628},[619,1234,1007],{"class":648},[619,1236,1237],{"class":621,"line":678},[619,1238,681],{"class":648},[619,1240,1241,1243,1245,1247,1249],{"class":621,"line":684},[619,1242,687],{"class":628},[619,1244,690],{"class":624},[619,1246,1022],{"class":648},[619,1248,696],{"class":624},[619,1250,985],{"class":648},[619,1252,1253],{"class":621,"line":701},[619,1254,704],{"class":648},[619,1256,1257],{"class":621,"line":707},[619,1258,634],{"emptyLinePlaceholder":103},[619,1260,1261,1263,1265,1267],{"class":621,"line":712},[619,1262,666],{"class":624},[619,1264,669],{"class":624},[619,1266,951],{"class":642},[619,1268,1048],{"class":648},[619,1270,1271],{"class":621,"line":725},[619,1272,681],{"class":648},[619,1274,1275],{"class":621,"line":730},[619,1276,1277],{"class":775},"        \u002F\u002F Slack Logic Here\n",[619,1279,1280],{"class":621,"line":744},[619,1281,704],{"class":648},[619,1283,1284],{"class":621,"line":749},[619,1285,820],{"class":648},[600,1287,1289],{"id":1288},"open-closed-principle-ocp","Open-Closed Principle (OCP)",[573,1291,1292],{},"The entire idea of the Open-Closed Principle, is so that your classes should be easily extendible without the need of editing the classes directly.",[573,1294,1295],{},"In our previous example regarding the Notifier you saw that we were able to easily add new Notification channels without ever having to modify any of the existing classes. This is exactly what this principle is trying to enforce.",[573,1297,1298],{},"One thing you'll notice is that all of the Principles play together hand and hand.",[573,1300,1301],{},"Let's look at another example of how this works by creating a trait for Vehicle with some predefined methods. We'll then create a new class for each body style while including the trait.",[573,1303,1304],{},"You could also use an Abstract class to accomplish the same thing.",[611,1306,1308],{"className":613,"code":1307,"language":119,"meta":615,"style":615},"\u003C?php\n\ntrait Vehicle\n{\n    protected $type;\n    protected $make;\n    protected $model;\n    protected $year;\n\n    public function type() : string\n    {\n        return __CLASS__;\n    }\n\n    public function make() : string\n    {\n        return $this->make;\n    }\n\n    public function model() : string\n    {\n        return $this->model;\n    }\n\n    public function year() : int\n    {\n        return $this->year;\n    }\n}\n\nclass Sedan\n{\n    use Vehicle;\n\n    public function __construct(string $make, string $model, int $year)\n    {\n        $this->make = $make;\n        $this->model = $model;\n        $this->year = $year;\n    }\n}\n\nclass Coupe\n{\n    use Vehicle;\n\n    public function __construct(string $make, string $model, int $year)\n    {\n        $this->make = $make;\n        $this->model = $model;\n        $this->year = $year;\n    }\n}\n",[587,1309,1310,1316,1320,1328,1332,1340,1347,1354,1361,1365,1383,1387,1397,1401,1405,1420,1424,1435,1439,1443,1458,1462,1473,1477,1481,1497,1501,1512,1516,1520,1524,1531,1535,1545,1549,1576,1580,1593,1606,1619,1623,1627,1631,1638,1642,1650,1654,1676,1680,1692,1704,1716,1721],{"__ignoreMap":615},[619,1311,1312,1314],{"class":621,"line":73},[619,1313,625],{"class":624},[619,1315,629],{"class":628},[619,1317,1318],{"class":621,"line":44},[619,1319,634],{"emptyLinePlaceholder":103},[619,1321,1322,1325],{"class":621,"line":102},[619,1323,1324],{"class":624},"trait",[619,1326,1327],{"class":642}," Vehicle\n",[619,1329,1330],{"class":621,"line":13},[619,1331,649],{"class":648},[619,1333,1334,1337],{"class":621,"line":61},[619,1335,1336],{"class":624},"    protected",[619,1338,1339],{"class":648}," $type;\n",[619,1341,1342,1344],{"class":621,"line":46},[619,1343,1336],{"class":624},[619,1345,1346],{"class":648}," $make;\n",[619,1348,1349,1351],{"class":621,"line":10},[619,1350,1336],{"class":624},[619,1352,1353],{"class":648}," $model;\n",[619,1355,1356,1358],{"class":621,"line":678},[619,1357,1336],{"class":624},[619,1359,1360],{"class":648}," $year;\n",[619,1362,1363],{"class":621,"line":684},[619,1364,634],{"emptyLinePlaceholder":103},[619,1366,1367,1369,1371,1374,1377,1380],{"class":621,"line":701},[619,1368,666],{"class":624},[619,1370,669],{"class":624},[619,1372,1373],{"class":642}," type",[619,1375,1376],{"class":648},"() ",[619,1378,1379],{"class":624},":",[619,1381,1382],{"class":624}," string\n",[619,1384,1385],{"class":621,"line":707},[619,1386,681],{"class":648},[619,1388,1389,1391,1394],{"class":621,"line":712},[619,1390,733],{"class":624},[619,1392,1393],{"class":628}," __CLASS__",[619,1395,1396],{"class":648},";\n",[619,1398,1399],{"class":621,"line":725},[619,1400,704],{"class":648},[619,1402,1403],{"class":621,"line":730},[619,1404,634],{"emptyLinePlaceholder":103},[619,1406,1407,1409,1411,1414,1416,1418],{"class":621,"line":744},[619,1408,666],{"class":624},[619,1410,669],{"class":624},[619,1412,1413],{"class":642}," make",[619,1415,1376],{"class":648},[619,1417,1379],{"class":624},[619,1419,1382],{"class":624},[619,1421,1422],{"class":621,"line":749},[619,1423,681],{"class":648},[619,1425,1426,1428,1430,1432],{"class":621,"line":754},[619,1427,733],{"class":624},[619,1429,736],{"class":628},[619,1431,690],{"class":624},[619,1433,1434],{"class":648},"make;\n",[619,1436,1437],{"class":621,"line":767},[619,1438,704],{"class":648},[619,1440,1441],{"class":621,"line":772},[619,1442,634],{"emptyLinePlaceholder":103},[619,1444,1445,1447,1449,1452,1454,1456],{"class":621,"line":779},[619,1446,666],{"class":624},[619,1448,669],{"class":624},[619,1450,1451],{"class":642}," model",[619,1453,1376],{"class":648},[619,1455,1379],{"class":624},[619,1457,1382],{"class":624},[619,1459,1460],{"class":621,"line":784},[619,1461,681],{"class":648},[619,1463,1464,1466,1468,1470],{"class":621,"line":789},[619,1465,733],{"class":624},[619,1467,736],{"class":628},[619,1469,690],{"class":624},[619,1471,1472],{"class":648},"model;\n",[619,1474,1475],{"class":621,"line":802},[619,1476,704],{"class":648},[619,1478,1479],{"class":621,"line":807},[619,1480,634],{"emptyLinePlaceholder":103},[619,1482,1483,1485,1487,1490,1492,1494],{"class":621,"line":812},[619,1484,666],{"class":624},[619,1486,669],{"class":624},[619,1488,1489],{"class":642}," year",[619,1491,1376],{"class":648},[619,1493,1379],{"class":624},[619,1495,1496],{"class":624}," int\n",[619,1498,1499],{"class":621,"line":817},[619,1500,681],{"class":648},[619,1502,1503,1505,1507,1509],{"class":621,"line":992},[619,1504,733],{"class":624},[619,1506,736],{"class":628},[619,1508,690],{"class":624},[619,1510,1511],{"class":648},"year;\n",[619,1513,1514],{"class":621,"line":1010},[619,1515,704],{"class":648},[619,1517,1518],{"class":621,"line":1015},[619,1519,820],{"class":648},[619,1521,1522],{"class":621,"line":1029},[619,1523,634],{"emptyLinePlaceholder":103},[619,1525,1526,1528],{"class":621,"line":1034},[619,1527,639],{"class":624},[619,1529,1530],{"class":642}," Sedan\n",[619,1532,1533],{"class":621,"line":1039},[619,1534,649],{"class":648},[619,1536,1537,1540,1543],{"class":621,"line":1051},[619,1538,1539],{"class":624},"    use",[619,1541,1542],{"class":628}," Vehicle",[619,1544,1396],{"class":648},[619,1546,1547],{"class":621,"line":1056},[619,1548,634],{"emptyLinePlaceholder":103},[619,1550,1551,1553,1555,1557,1559,1562,1565,1567,1570,1573],{"class":621,"line":1062},[619,1552,666],{"class":624},[619,1554,669],{"class":624},[619,1556,672],{"class":628},[619,1558,1001],{"class":648},[619,1560,1561],{"class":624},"string",[619,1563,1564],{"class":648}," $make, ",[619,1566,1561],{"class":624},[619,1568,1569],{"class":648}," $model, ",[619,1571,1572],{"class":624},"int",[619,1574,1575],{"class":648}," $year)\n",[619,1577,1578],{"class":621,"line":1067},[619,1579,681],{"class":648},[619,1581,1582,1584,1586,1589,1591],{"class":621,"line":1072},[619,1583,687],{"class":628},[619,1585,690],{"class":624},[619,1587,1588],{"class":648},"make ",[619,1590,696],{"class":624},[619,1592,1346],{"class":648},[619,1594,1595,1597,1599,1602,1604],{"class":621,"line":49},[619,1596,687],{"class":628},[619,1598,690],{"class":624},[619,1600,1601],{"class":648},"model ",[619,1603,696],{"class":624},[619,1605,1353],{"class":648},[619,1607,1608,1610,1612,1615,1617],{"class":621,"line":1088},[619,1609,687],{"class":628},[619,1611,690],{"class":624},[619,1613,1614],{"class":648},"year ",[619,1616,696],{"class":624},[619,1618,1360],{"class":648},[619,1620,1621],{"class":621,"line":1093},[619,1622,704],{"class":648},[619,1624,1625],{"class":621,"line":1100},[619,1626,820],{"class":648},[619,1628,1629],{"class":621,"line":1105},[619,1630,634],{"emptyLinePlaceholder":103},[619,1632,1633,1635],{"class":621,"line":1120},[619,1634,639],{"class":624},[619,1636,1637],{"class":642}," Coupe\n",[619,1639,1640],{"class":621,"line":1125},[619,1641,649],{"class":648},[619,1643,1644,1646,1648],{"class":621,"line":1138},[619,1645,1539],{"class":624},[619,1647,1542],{"class":628},[619,1649,1396],{"class":648},[619,1651,1652],{"class":621,"line":1143},[619,1653,634],{"emptyLinePlaceholder":103},[619,1655,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674],{"class":621,"line":1148},[619,1657,666],{"class":624},[619,1659,669],{"class":624},[619,1661,672],{"class":628},[619,1663,1001],{"class":648},[619,1665,1561],{"class":624},[619,1667,1564],{"class":648},[619,1669,1561],{"class":624},[619,1671,1569],{"class":648},[619,1673,1572],{"class":624},[619,1675,1575],{"class":648},[619,1677,1678],{"class":621,"line":1159},[619,1679,681],{"class":648},[619,1681,1682,1684,1686,1688,1690],{"class":621,"line":1164},[619,1683,687],{"class":628},[619,1685,690],{"class":624},[619,1687,1588],{"class":648},[619,1689,696],{"class":624},[619,1691,1346],{"class":648},[619,1693,1694,1696,1698,1700,1702],{"class":621,"line":1170},[619,1695,687],{"class":628},[619,1697,690],{"class":624},[619,1699,1601],{"class":648},[619,1701,696],{"class":624},[619,1703,1353],{"class":648},[619,1705,1706,1708,1710,1712,1714],{"class":621,"line":1175},[619,1707,687],{"class":628},[619,1709,690],{"class":624},[619,1711,1614],{"class":648},[619,1713,696],{"class":624},[619,1715,1360],{"class":648},[619,1717,1719],{"class":621,"line":1718},52,[619,1720,704],{"class":648},[619,1722,1724],{"class":621,"line":1723},53,[619,1725,820],{"class":648},[573,1727,1728],{},"Notice that now we can just continue making new body styles without ever modifying any of the existing classes.",[573,1730,1731],{},"Let's make another body style for Convertible.",[611,1733,1735],{"className":613,"code":1734,"language":119,"meta":615,"style":615},"\u003C?php\n\nclass Convertible\n{\n    use Vehicle;\n\n    public function __construct(string $make, string $model, int $year)\n    {\n        $this->make = $make;\n        $this->model = $model;\n        $this->year = $year;\n    }\n}\n",[587,1736,1737,1743,1747,1754,1758,1766,1770,1792,1796,1808,1820,1832,1836],{"__ignoreMap":615},[619,1738,1739,1741],{"class":621,"line":73},[619,1740,625],{"class":624},[619,1742,629],{"class":628},[619,1744,1745],{"class":621,"line":44},[619,1746,634],{"emptyLinePlaceholder":103},[619,1748,1749,1751],{"class":621,"line":102},[619,1750,639],{"class":624},[619,1752,1753],{"class":642}," Convertible\n",[619,1755,1756],{"class":621,"line":13},[619,1757,649],{"class":648},[619,1759,1760,1762,1764],{"class":621,"line":61},[619,1761,1539],{"class":624},[619,1763,1542],{"class":628},[619,1765,1396],{"class":648},[619,1767,1768],{"class":621,"line":46},[619,1769,634],{"emptyLinePlaceholder":103},[619,1771,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790],{"class":621,"line":10},[619,1773,666],{"class":624},[619,1775,669],{"class":624},[619,1777,672],{"class":628},[619,1779,1001],{"class":648},[619,1781,1561],{"class":624},[619,1783,1564],{"class":648},[619,1785,1561],{"class":624},[619,1787,1569],{"class":648},[619,1789,1572],{"class":624},[619,1791,1575],{"class":648},[619,1793,1794],{"class":621,"line":678},[619,1795,681],{"class":648},[619,1797,1798,1800,1802,1804,1806],{"class":621,"line":684},[619,1799,687],{"class":628},[619,1801,690],{"class":624},[619,1803,1588],{"class":648},[619,1805,696],{"class":624},[619,1807,1346],{"class":648},[619,1809,1810,1812,1814,1816,1818],{"class":621,"line":701},[619,1811,687],{"class":628},[619,1813,690],{"class":624},[619,1815,1601],{"class":648},[619,1817,696],{"class":624},[619,1819,1353],{"class":648},[619,1821,1822,1824,1826,1828,1830],{"class":621,"line":707},[619,1823,687],{"class":628},[619,1825,690],{"class":624},[619,1827,1614],{"class":648},[619,1829,696],{"class":624},[619,1831,1360],{"class":648},[619,1833,1834],{"class":621,"line":712},[619,1835,704],{"class":648},[619,1837,1838],{"class":621,"line":725},[619,1839,820],{"class":648},[573,1841,1842],{},"You see how simple it is now, to add additional body styles for our application.",[600,1844,1846],{"id":1845},"liskov-substitution-principle-lsp","Liskov Substitution Principle (LSP)",[573,1848,1849],{},"The idea behind the Liskov Substitution Principle is that a child class should never break its parent class. Instead we should be able to swap out any class of the same type with another while the application continues to work as normal.",[573,1851,1852],{},"Let's add a bit more functionality to our Notification example from the first principle.",[611,1854,1856],{"className":613,"code":1855,"language":119,"meta":615,"style":615},"\u003C?php\n\nclass Notify\n{\n    private $notifier;\n\n    public function send(Notifier $notifier)\n    {\n        $this->notifier = $notifier;\n\n        return $this;\n    }\n\n    public function to(string $to)\n    {\n        return $this->notifier->send($to);\n    }\n}\n\nclass Notification\n{\n    private $message;\n\n    public function __construct($message)\n    {\n        $this->message = $message;\n    }\n\n    public function message()\n    {\n        return $this->message;\n    }\n}\n\ninterface Notifier\n{\n    public function send($to);\n}\n\nclass EmailNotifier implements Notifier\n{\n    private $notification;\n\n    public function __construct(Notification $notification)\n    {\n        $this->notification = $notification;\n    }\n\n    public function send($to)\n    {\n        \u002F\u002F Email Logic Here\n    }\n}\n\nclass SMSNotifier implements Notifier\n{\n    private $notification;\n\n    public function __construct(Notification $notification)\n    {\n        $this->notification = $notification;\n    }\n\n    public function send($to)\n    {\n        \u002F\u002F SMS Logic Here\n    }\n}\n",[587,1857,1858,1864,1868,1875,1879,1886,1890,1906,1910,1923,1927,1935,1939,1943,1959,1963,1981,1985,1989,1993,1999,2003,2009,2013,2023,2027,2039,2043,2047,2057,2061,2071,2075,2079,2083,2089,2093,2103,2107,2111,2121,2125,2131,2135,2149,2153,2165,2169,2173,2183,2187,2191,2195,2199,2204,2214,2219,2226,2231,2246,2251,2264,2269,2274,2285,2290,2295,2300],{"__ignoreMap":615},[619,1859,1860,1862],{"class":621,"line":73},[619,1861,625],{"class":624},[619,1863,629],{"class":628},[619,1865,1866],{"class":621,"line":44},[619,1867,634],{"emptyLinePlaceholder":103},[619,1869,1870,1872],{"class":621,"line":102},[619,1871,639],{"class":624},[619,1873,1874],{"class":642}," Notify\n",[619,1876,1877],{"class":621,"line":13},[619,1878,649],{"class":648},[619,1880,1881,1883],{"class":621,"line":61},[619,1882,654],{"class":624},[619,1884,1885],{"class":648}," $notifier;\n",[619,1887,1888],{"class":621,"line":46},[619,1889,634],{"emptyLinePlaceholder":103},[619,1891,1892,1894,1896,1898,1900,1903],{"class":621,"line":10},[619,1893,666],{"class":624},[619,1895,669],{"class":624},[619,1897,951],{"class":642},[619,1899,1001],{"class":648},[619,1901,1902],{"class":628},"Notifier",[619,1904,1905],{"class":648}," $notifier)\n",[619,1907,1908],{"class":621,"line":678},[619,1909,681],{"class":648},[619,1911,1912,1914,1916,1919,1921],{"class":621,"line":684},[619,1913,687],{"class":628},[619,1915,690],{"class":624},[619,1917,1918],{"class":648},"notifier ",[619,1920,696],{"class":624},[619,1922,1885],{"class":648},[619,1924,1925],{"class":621,"line":701},[619,1926,634],{"emptyLinePlaceholder":103},[619,1928,1929,1931,1933],{"class":621,"line":707},[619,1930,733],{"class":624},[619,1932,736],{"class":628},[619,1934,1396],{"class":648},[619,1936,1937],{"class":621,"line":712},[619,1938,704],{"class":648},[619,1940,1941],{"class":621,"line":725},[619,1942,634],{"emptyLinePlaceholder":103},[619,1944,1945,1947,1949,1952,1954,1956],{"class":621,"line":730},[619,1946,666],{"class":624},[619,1948,669],{"class":624},[619,1950,1951],{"class":642}," to",[619,1953,1001],{"class":648},[619,1955,1561],{"class":624},[619,1957,1958],{"class":648}," $to)\n",[619,1960,1961],{"class":621,"line":744},[619,1962,681],{"class":648},[619,1964,1965,1967,1969,1971,1974,1976,1979],{"class":621,"line":749},[619,1966,733],{"class":624},[619,1968,736],{"class":628},[619,1970,690],{"class":624},[619,1972,1973],{"class":648},"notifier",[619,1975,690],{"class":624},[619,1977,1978],{"class":642},"send",[619,1980,954],{"class":648},[619,1982,1983],{"class":621,"line":754},[619,1984,704],{"class":648},[619,1986,1987],{"class":621,"line":767},[619,1988,820],{"class":648},[619,1990,1991],{"class":621,"line":772},[619,1992,634],{"emptyLinePlaceholder":103},[619,1994,1995,1997],{"class":621,"line":779},[619,1996,639],{"class":624},[619,1998,643],{"class":642},[619,2000,2001],{"class":621,"line":784},[619,2002,649],{"class":648},[619,2004,2005,2007],{"class":621,"line":789},[619,2006,654],{"class":624},[619,2008,657],{"class":648},[619,2010,2011],{"class":621,"line":802},[619,2012,634],{"emptyLinePlaceholder":103},[619,2014,2015,2017,2019,2021],{"class":621,"line":807},[619,2016,666],{"class":624},[619,2018,669],{"class":624},[619,2020,672],{"class":628},[619,2022,675],{"class":648},[619,2024,2025],{"class":621,"line":812},[619,2026,681],{"class":648},[619,2028,2029,2031,2033,2035,2037],{"class":621,"line":817},[619,2030,687],{"class":628},[619,2032,690],{"class":624},[619,2034,693],{"class":648},[619,2036,696],{"class":624},[619,2038,657],{"class":648},[619,2040,2041],{"class":621,"line":992},[619,2042,704],{"class":648},[619,2044,2045],{"class":621,"line":1010},[619,2046,634],{"emptyLinePlaceholder":103},[619,2048,2049,2051,2053,2055],{"class":621,"line":1015},[619,2050,666],{"class":624},[619,2052,669],{"class":624},[619,2054,719],{"class":642},[619,2056,722],{"class":648},[619,2058,2059],{"class":621,"line":1029},[619,2060,681],{"class":648},[619,2062,2063,2065,2067,2069],{"class":621,"line":1034},[619,2064,733],{"class":624},[619,2066,736],{"class":628},[619,2068,690],{"class":624},[619,2070,741],{"class":648},[619,2072,2073],{"class":621,"line":1039},[619,2074,704],{"class":648},[619,2076,2077],{"class":621,"line":1051},[619,2078,820],{"class":648},[619,2080,2081],{"class":621,"line":1056},[619,2082,634],{"emptyLinePlaceholder":103},[619,2084,2085,2087],{"class":621,"line":1062},[619,2086,589],{"class":624},[619,2088,938],{"class":642},[619,2090,2091],{"class":621,"line":1067},[619,2092,649],{"class":648},[619,2094,2095,2097,2099,2101],{"class":621,"line":1072},[619,2096,666],{"class":624},[619,2098,669],{"class":624},[619,2100,951],{"class":642},[619,2102,954],{"class":648},[619,2104,2105],{"class":621,"line":49},[619,2106,820],{"class":648},[619,2108,2109],{"class":621,"line":1088},[619,2110,634],{"emptyLinePlaceholder":103},[619,2112,2113,2115,2117,2119],{"class":621,"line":1093},[619,2114,639],{"class":624},[619,2116,969],{"class":642},[619,2118,972],{"class":624},[619,2120,938],{"class":642},[619,2122,2123],{"class":621,"line":1100},[619,2124,649],{"class":648},[619,2126,2127,2129],{"class":621,"line":1105},[619,2128,654],{"class":624},[619,2130,985],{"class":648},[619,2132,2133],{"class":621,"line":1120},[619,2134,634],{"emptyLinePlaceholder":103},[619,2136,2137,2139,2141,2143,2145,2147],{"class":621,"line":1125},[619,2138,666],{"class":624},[619,2140,669],{"class":624},[619,2142,672],{"class":628},[619,2144,1001],{"class":648},[619,2146,1004],{"class":628},[619,2148,1007],{"class":648},[619,2150,2151],{"class":621,"line":1138},[619,2152,681],{"class":648},[619,2154,2155,2157,2159,2161,2163],{"class":621,"line":1143},[619,2156,687],{"class":628},[619,2158,690],{"class":624},[619,2160,1022],{"class":648},[619,2162,696],{"class":624},[619,2164,985],{"class":648},[619,2166,2167],{"class":621,"line":1148},[619,2168,704],{"class":648},[619,2170,2171],{"class":621,"line":1159},[619,2172,634],{"emptyLinePlaceholder":103},[619,2174,2175,2177,2179,2181],{"class":621,"line":1164},[619,2176,666],{"class":624},[619,2178,669],{"class":624},[619,2180,951],{"class":642},[619,2182,1048],{"class":648},[619,2184,2185],{"class":621,"line":1170},[619,2186,681],{"class":648},[619,2188,2189],{"class":621,"line":1175},[619,2190,1059],{"class":775},[619,2192,2193],{"class":621,"line":1718},[619,2194,704],{"class":648},[619,2196,2197],{"class":621,"line":1723},[619,2198,820],{"class":648},[619,2200,2202],{"class":621,"line":2201},54,[619,2203,634],{"emptyLinePlaceholder":103},[619,2205,2206,2208,2210,2212],{"class":621,"line":154},[619,2207,639],{"class":624},[619,2209,1081],{"class":642},[619,2211,972],{"class":624},[619,2213,938],{"class":642},[619,2215,2217],{"class":621,"line":2216},56,[619,2218,649],{"class":648},[619,2220,2222,2224],{"class":621,"line":2221},57,[619,2223,654],{"class":624},[619,2225,985],{"class":648},[619,2227,2229],{"class":621,"line":2228},58,[619,2230,634],{"emptyLinePlaceholder":103},[619,2232,2234,2236,2238,2240,2242,2244],{"class":621,"line":2233},59,[619,2235,666],{"class":624},[619,2237,669],{"class":624},[619,2239,672],{"class":628},[619,2241,1001],{"class":648},[619,2243,1004],{"class":628},[619,2245,1007],{"class":648},[619,2247,2249],{"class":621,"line":2248},60,[619,2250,681],{"class":648},[619,2252,2254,2256,2258,2260,2262],{"class":621,"line":2253},61,[619,2255,687],{"class":628},[619,2257,690],{"class":624},[619,2259,1022],{"class":648},[619,2261,696],{"class":624},[619,2263,985],{"class":648},[619,2265,2267],{"class":621,"line":2266},62,[619,2268,704],{"class":648},[619,2270,2272],{"class":621,"line":2271},63,[619,2273,634],{"emptyLinePlaceholder":103},[619,2275,2277,2279,2281,2283],{"class":621,"line":2276},64,[619,2278,666],{"class":624},[619,2280,669],{"class":624},[619,2282,951],{"class":642},[619,2284,1048],{"class":648},[619,2286,2288],{"class":621,"line":2287},65,[619,2289,681],{"class":648},[619,2291,2293],{"class":621,"line":2292},66,[619,2294,1167],{"class":775},[619,2296,2298],{"class":621,"line":2297},67,[619,2299,704],{"class":648},[619,2301,2303],{"class":621,"line":2302},68,[619,2304,820],{"class":648},[573,2306,2307],{},"You'll see that we added a Notify class that is capable of running a Notifier instance. Let me show you how we'd go about using this.",[611,2309,2311],{"className":613,"code":2310,"language":119,"meta":615,"style":615},"\u003C?php\n\n$notification = new Notification('Test Message');\n\n$notify = new Notify();\n\n\u002F\u002F Send Email Notification\n$notify->send(new EmailNotifier($notification))->to('fake@email-fake.com');\n\n\u002F\u002F Send SMS Notification\n$notify->send(new SMSNotifier($notification))->to('+19999999999');\n",[587,2312,2313,2319,2323,2345,2349,2364,2368,2373,2404,2408,2413],{"__ignoreMap":615},[619,2314,2315,2317],{"class":621,"line":73},[619,2316,625],{"class":624},[619,2318,629],{"class":628},[619,2320,2321],{"class":621,"line":44},[619,2322,634],{"emptyLinePlaceholder":103},[619,2324,2325,2328,2330,2333,2336,2338,2342],{"class":621,"line":102},[619,2326,2327],{"class":648},"$notification ",[619,2329,696],{"class":624},[619,2331,2332],{"class":624}," new",[619,2334,2335],{"class":628}," Notification",[619,2337,1001],{"class":648},[619,2339,2341],{"class":2340},"s4wv1","'Test Message'",[619,2343,2344],{"class":648},");\n",[619,2346,2347],{"class":621,"line":13},[619,2348,634],{"emptyLinePlaceholder":103},[619,2350,2351,2354,2356,2358,2361],{"class":621,"line":61},[619,2352,2353],{"class":648},"$notify ",[619,2355,696],{"class":624},[619,2357,2332],{"class":624},[619,2359,2360],{"class":628}," Notify",[619,2362,2363],{"class":648},"();\n",[619,2365,2366],{"class":621,"line":46},[619,2367,634],{"emptyLinePlaceholder":103},[619,2369,2370],{"class":621,"line":10},[619,2371,2372],{"class":775},"\u002F\u002F Send Email Notification\n",[619,2374,2375,2378,2380,2382,2384,2387,2389,2392,2394,2397,2399,2402],{"class":621,"line":678},[619,2376,2377],{"class":648},"$notify",[619,2379,690],{"class":624},[619,2381,1978],{"class":642},[619,2383,1001],{"class":648},[619,2385,2386],{"class":624},"new",[619,2388,969],{"class":628},[619,2390,2391],{"class":648},"($notification))",[619,2393,690],{"class":624},[619,2395,2396],{"class":642},"to",[619,2398,1001],{"class":648},[619,2400,2401],{"class":2340},"'fake@email-fake.com'",[619,2403,2344],{"class":648},[619,2405,2406],{"class":621,"line":684},[619,2407,634],{"emptyLinePlaceholder":103},[619,2409,2410],{"class":621,"line":701},[619,2411,2412],{"class":775},"\u002F\u002F Send SMS Notification\n",[619,2414,2415,2417,2419,2421,2423,2425,2427,2429,2431,2433,2435,2438],{"class":621,"line":707},[619,2416,2377],{"class":648},[619,2418,690],{"class":624},[619,2420,1978],{"class":642},[619,2422,1001],{"class":648},[619,2424,2386],{"class":624},[619,2426,1081],{"class":628},[619,2428,2391],{"class":648},[619,2430,690],{"class":624},[619,2432,2396],{"class":642},[619,2434,1001],{"class":648},[619,2436,2437],{"class":2340},"'+19999999999'",[619,2439,2344],{"class":648},[573,2441,2442],{},"You see how easy it is to swap out the Notifier within our Notify class. This is amazing and should improve the ease of working within our code base.",[600,2444,2446],{"id":2445},"interface-segregation-principle-isp","Interface Segregation Principle (ISP)",[573,2448,2449],{},"Interface Segregation Principle states that no class should be forced to use methods it does not need. One way to solve this is to keep your interfaces, abstract classes, and traits small by creating multiple instead of a single large one.",[573,2451,2452],{},"Let's take an example of a Paper Book. With a book you can flip to the next page and go to the previous page. If we're reading on a Kindle though, you'll be able to easily bookmark a page, apart from the regular page flipping functionality.",[573,2454,2455],{},"This is how we may handle something like this.",[573,2457,2458],{},"Keep in mind that this is a bare bones example, and there is still more that we would need to pass to actually have a functional system. Such as the actual book contents, and implementations of each method. I kept it short for the sake of this example.",[611,2460,2462],{"className":613,"code":2461,"language":119,"meta":615,"style":615},"\u003C?php\n\ninterface ElectronicReader\n{\n    public function bookmarkPage();\n}\n\ninterface Book\n{\n    public function nextPage();\n\n    public function previousPage();\n}\n\nclass PaperBook implements Book\n{\n    public function nextPage()\n    {\n        \u002F\u002F Advance to the next page.\n    }\n\n    public function previousPage()\n    {\n        \u002F\u002F Return to the previous page.\n    }\n}\n\nclass Kindle implements Book, ElectronicReader\n{\n    public function nextPage()\n    {\n        \u002F\u002F Advance to the next page.\n    }\n\n    public function previousPage()\n    {\n        \u002F\u002F Return to the previous page.\n    }\n\n    public function bookmarkPage()\n    {\n        \u002F\u002F Save the reader's place.\n    }\n}\n",[587,2463,2464,2470,2474,2481,2485,2496,2500,2504,2511,2515,2526,2530,2541,2545,2549,2560,2564,2574,2578,2583,2587,2591,2601,2605,2610,2614,2618,2622,2639,2643,2653,2657,2661,2665,2669,2679,2683,2687,2691,2695,2705,2709,2714,2718],{"__ignoreMap":615},[619,2465,2466,2468],{"class":621,"line":73},[619,2467,625],{"class":624},[619,2469,629],{"class":628},[619,2471,2472],{"class":621,"line":44},[619,2473,634],{"emptyLinePlaceholder":103},[619,2475,2476,2478],{"class":621,"line":102},[619,2477,589],{"class":624},[619,2479,2480],{"class":642}," ElectronicReader\n",[619,2482,2483],{"class":621,"line":13},[619,2484,649],{"class":648},[619,2486,2487,2489,2491,2494],{"class":621,"line":61},[619,2488,666],{"class":624},[619,2490,669],{"class":624},[619,2492,2493],{"class":642}," bookmarkPage",[619,2495,2363],{"class":648},[619,2497,2498],{"class":621,"line":46},[619,2499,820],{"class":648},[619,2501,2502],{"class":621,"line":10},[619,2503,634],{"emptyLinePlaceholder":103},[619,2505,2506,2508],{"class":621,"line":678},[619,2507,589],{"class":624},[619,2509,2510],{"class":642}," Book\n",[619,2512,2513],{"class":621,"line":684},[619,2514,649],{"class":648},[619,2516,2517,2519,2521,2524],{"class":621,"line":701},[619,2518,666],{"class":624},[619,2520,669],{"class":624},[619,2522,2523],{"class":642}," nextPage",[619,2525,2363],{"class":648},[619,2527,2528],{"class":621,"line":707},[619,2529,634],{"emptyLinePlaceholder":103},[619,2531,2532,2534,2536,2539],{"class":621,"line":712},[619,2533,666],{"class":624},[619,2535,669],{"class":624},[619,2537,2538],{"class":642}," previousPage",[619,2540,2363],{"class":648},[619,2542,2543],{"class":621,"line":725},[619,2544,820],{"class":648},[619,2546,2547],{"class":621,"line":730},[619,2548,634],{"emptyLinePlaceholder":103},[619,2550,2551,2553,2556,2558],{"class":621,"line":744},[619,2552,639],{"class":624},[619,2554,2555],{"class":642}," PaperBook",[619,2557,972],{"class":624},[619,2559,2510],{"class":642},[619,2561,2562],{"class":621,"line":749},[619,2563,649],{"class":648},[619,2565,2566,2568,2570,2572],{"class":621,"line":754},[619,2567,666],{"class":624},[619,2569,669],{"class":624},[619,2571,2523],{"class":642},[619,2573,722],{"class":648},[619,2575,2576],{"class":621,"line":767},[619,2577,681],{"class":648},[619,2579,2580],{"class":621,"line":772},[619,2581,2582],{"class":775},"        \u002F\u002F Advance to the next page.\n",[619,2584,2585],{"class":621,"line":779},[619,2586,704],{"class":648},[619,2588,2589],{"class":621,"line":784},[619,2590,634],{"emptyLinePlaceholder":103},[619,2592,2593,2595,2597,2599],{"class":621,"line":789},[619,2594,666],{"class":624},[619,2596,669],{"class":624},[619,2598,2538],{"class":642},[619,2600,722],{"class":648},[619,2602,2603],{"class":621,"line":802},[619,2604,681],{"class":648},[619,2606,2607],{"class":621,"line":807},[619,2608,2609],{"class":775},"        \u002F\u002F Return to the previous page.\n",[619,2611,2612],{"class":621,"line":812},[619,2613,704],{"class":648},[619,2615,2616],{"class":621,"line":817},[619,2617,820],{"class":648},[619,2619,2620],{"class":621,"line":992},[619,2621,634],{"emptyLinePlaceholder":103},[619,2623,2624,2626,2629,2631,2634,2636],{"class":621,"line":1010},[619,2625,639],{"class":624},[619,2627,2628],{"class":642}," Kindle",[619,2630,972],{"class":624},[619,2632,2633],{"class":642}," Book",[619,2635,590],{"class":648},[619,2637,2638],{"class":642},"ElectronicReader\n",[619,2640,2641],{"class":621,"line":1015},[619,2642,649],{"class":648},[619,2644,2645,2647,2649,2651],{"class":621,"line":1029},[619,2646,666],{"class":624},[619,2648,669],{"class":624},[619,2650,2523],{"class":642},[619,2652,722],{"class":648},[619,2654,2655],{"class":621,"line":1034},[619,2656,681],{"class":648},[619,2658,2659],{"class":621,"line":1039},[619,2660,2582],{"class":775},[619,2662,2663],{"class":621,"line":1051},[619,2664,704],{"class":648},[619,2666,2667],{"class":621,"line":1056},[619,2668,634],{"emptyLinePlaceholder":103},[619,2670,2671,2673,2675,2677],{"class":621,"line":1062},[619,2672,666],{"class":624},[619,2674,669],{"class":624},[619,2676,2538],{"class":642},[619,2678,722],{"class":648},[619,2680,2681],{"class":621,"line":1067},[619,2682,681],{"class":648},[619,2684,2685],{"class":621,"line":1072},[619,2686,2609],{"class":775},[619,2688,2689],{"class":621,"line":49},[619,2690,704],{"class":648},[619,2692,2693],{"class":621,"line":1088},[619,2694,634],{"emptyLinePlaceholder":103},[619,2696,2697,2699,2701,2703],{"class":621,"line":1093},[619,2698,666],{"class":624},[619,2700,669],{"class":624},[619,2702,2493],{"class":642},[619,2704,722],{"class":648},[619,2706,2707],{"class":621,"line":1100},[619,2708,681],{"class":648},[619,2710,2711],{"class":621,"line":1105},[619,2712,2713],{"class":775},"        \u002F\u002F Save the reader's place.\n",[619,2715,2716],{"class":621,"line":1120},[619,2717,704],{"class":648},[619,2719,2720],{"class":621,"line":1125},[619,2721,820],{"class":648},[600,2723,2725],{"id":2724},"dependency-inversion-principle-dip","Dependency Inversion Principle (DIP)",[573,2727,2728],{},"Lastly, we have the Dependency Inversion Principle which is my favorite. The idea behind this is that your classes should not know the details of how the object is setup. Instead an object should be provided to your classes to use by dependency injection to your constructor or even method. This decouples your dependencies from your code base, allowing you to easily test your code and swap out instances of a class if needed with ease.",[573,2730,2731],{},"Let's look again at our Notifier code from earlier.",[611,2733,2735],{"className":613,"code":2734,"language":119,"meta":615,"style":615},"\u003C?php\n\nclass Notify\n{\n    private $notifier;\n\n    public function send(Notifier $notifier)\n    {\n        $this->notifier = $notifier;\n\n        return $this;\n    }\n\n    public function to(string $to)\n    {\n        return $this->notifier->send($to);\n    }\n}\n",[587,2736,2737,2743,2747,2753,2757,2763,2767,2781,2785,2797,2801,2809,2813,2817,2831,2835,2851,2855],{"__ignoreMap":615},[619,2738,2739,2741],{"class":621,"line":73},[619,2740,625],{"class":624},[619,2742,629],{"class":628},[619,2744,2745],{"class":621,"line":44},[619,2746,634],{"emptyLinePlaceholder":103},[619,2748,2749,2751],{"class":621,"line":102},[619,2750,639],{"class":624},[619,2752,1874],{"class":642},[619,2754,2755],{"class":621,"line":13},[619,2756,649],{"class":648},[619,2758,2759,2761],{"class":621,"line":61},[619,2760,654],{"class":624},[619,2762,1885],{"class":648},[619,2764,2765],{"class":621,"line":46},[619,2766,634],{"emptyLinePlaceholder":103},[619,2768,2769,2771,2773,2775,2777,2779],{"class":621,"line":10},[619,2770,666],{"class":624},[619,2772,669],{"class":624},[619,2774,951],{"class":642},[619,2776,1001],{"class":648},[619,2778,1902],{"class":628},[619,2780,1905],{"class":648},[619,2782,2783],{"class":621,"line":678},[619,2784,681],{"class":648},[619,2786,2787,2789,2791,2793,2795],{"class":621,"line":684},[619,2788,687],{"class":628},[619,2790,690],{"class":624},[619,2792,1918],{"class":648},[619,2794,696],{"class":624},[619,2796,1885],{"class":648},[619,2798,2799],{"class":621,"line":701},[619,2800,634],{"emptyLinePlaceholder":103},[619,2802,2803,2805,2807],{"class":621,"line":707},[619,2804,733],{"class":624},[619,2806,736],{"class":628},[619,2808,1396],{"class":648},[619,2810,2811],{"class":621,"line":712},[619,2812,704],{"class":648},[619,2814,2815],{"class":621,"line":725},[619,2816,634],{"emptyLinePlaceholder":103},[619,2818,2819,2821,2823,2825,2827,2829],{"class":621,"line":730},[619,2820,666],{"class":624},[619,2822,669],{"class":624},[619,2824,1951],{"class":642},[619,2826,1001],{"class":648},[619,2828,1561],{"class":624},[619,2830,1958],{"class":648},[619,2832,2833],{"class":621,"line":744},[619,2834,681],{"class":648},[619,2836,2837,2839,2841,2843,2845,2847,2849],{"class":621,"line":749},[619,2838,733],{"class":624},[619,2840,736],{"class":628},[619,2842,690],{"class":624},[619,2844,1973],{"class":648},[619,2846,690],{"class":624},[619,2848,1978],{"class":642},[619,2850,954],{"class":648},[619,2852,2853],{"class":621,"line":754},[619,2854,704],{"class":648},[619,2856,2857],{"class":621,"line":767},[619,2858,820],{"class":648},[573,2860,2861],{},"You'll see that on our send method, we're passing the name of the interface Notifier which our Notifier concrete classes will implement. Doing this allows us to easily swap out the way we send notifications without ever having to modify any of the code within our Notify class.",[573,2863,2864],{},"We were able to demonstrate this earlier by sending a SMS and Email Notification from the same Notify class. I've included the example again below.",[611,2866,2867],{"className":613,"code":2310,"language":119,"meta":615,"style":615},[587,2868,2869,2875,2879,2895,2899,2911,2915,2919,2945,2949,2953],{"__ignoreMap":615},[619,2870,2871,2873],{"class":621,"line":73},[619,2872,625],{"class":624},[619,2874,629],{"class":628},[619,2876,2877],{"class":621,"line":44},[619,2878,634],{"emptyLinePlaceholder":103},[619,2880,2881,2883,2885,2887,2889,2891,2893],{"class":621,"line":102},[619,2882,2327],{"class":648},[619,2884,696],{"class":624},[619,2886,2332],{"class":624},[619,2888,2335],{"class":628},[619,2890,1001],{"class":648},[619,2892,2341],{"class":2340},[619,2894,2344],{"class":648},[619,2896,2897],{"class":621,"line":13},[619,2898,634],{"emptyLinePlaceholder":103},[619,2900,2901,2903,2905,2907,2909],{"class":621,"line":61},[619,2902,2353],{"class":648},[619,2904,696],{"class":624},[619,2906,2332],{"class":624},[619,2908,2360],{"class":628},[619,2910,2363],{"class":648},[619,2912,2913],{"class":621,"line":46},[619,2914,634],{"emptyLinePlaceholder":103},[619,2916,2917],{"class":621,"line":10},[619,2918,2372],{"class":775},[619,2920,2921,2923,2925,2927,2929,2931,2933,2935,2937,2939,2941,2943],{"class":621,"line":678},[619,2922,2377],{"class":648},[619,2924,690],{"class":624},[619,2926,1978],{"class":642},[619,2928,1001],{"class":648},[619,2930,2386],{"class":624},[619,2932,969],{"class":628},[619,2934,2391],{"class":648},[619,2936,690],{"class":624},[619,2938,2396],{"class":642},[619,2940,1001],{"class":648},[619,2942,2401],{"class":2340},[619,2944,2344],{"class":648},[619,2946,2947],{"class":621,"line":684},[619,2948,634],{"emptyLinePlaceholder":103},[619,2950,2951],{"class":621,"line":701},[619,2952,2412],{"class":775},[619,2954,2955,2957,2959,2961,2963,2965,2967,2969,2971,2973,2975,2977],{"class":621,"line":707},[619,2956,2377],{"class":648},[619,2958,690],{"class":624},[619,2960,1978],{"class":642},[619,2962,1001],{"class":648},[619,2964,2386],{"class":624},[619,2966,1081],{"class":628},[619,2968,2391],{"class":648},[619,2970,690],{"class":624},[619,2972,2396],{"class":642},[619,2974,1001],{"class":648},[619,2976,2437],{"class":2340},[619,2978,2344],{"class":648},[600,2980,2982],{"id":2981},"conclusion","Conclusion",[573,2984,2985],{},"Following the above principles will improve your code base and make it easier for you and other developers to maintain and extend it. Don't worry if you're not following these 100%. They're only guidelines meant to help you improve the readability of your code, but not mandatory, if for some reason you do not like something about these principles, or do not agree with them. One thing I can guarantee though is that following these principles will definitely be beneficial in the long run.",[573,2987,2988],{},"The choice is yours.",[2990,2991,2992],"style",{},"html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}",{"title":615,"searchDepth":44,"depth":44,"links":2994},[2995,2996,2997,2998,2999,3000],{"id":602,"depth":44,"text":603},{"id":1288,"depth":44,"text":1289},{"id":1845,"depth":44,"text":1846},{"id":2445,"depth":44,"text":2446},{"id":2724,"depth":44,"text":2725},{"id":2981,"depth":44,"text":2982},{"id":73,"name":118,"slug":119,"hue":120},"md",{},{"title":441,"description":575},"posts\u002Fsolid-principles-in-php",[119],[3008],{"name":118,"slug":119},"TFNFzlijF4KeNlIYJUmuf8MNVWlU1IvRpbhqok0IUHY",1781454358264]