From f5c444d4c74d54def04e710db7e656eb6c98004e Mon Sep 17 00:00:00 2001 From: lubiana Date: Tue, 31 May 2022 18:05:46 +0200 Subject: [PATCH] fix typos in chapters 15 to 17 --- 15-adding-content.md | 24 ++++++++++++------------ 16-data-repository.md | 24 ++++++++++++------------ 17-performance.md | 14 +++++++------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/15-adding-content.md b/15-adding-content.md index 0e85af0..753c395 100644 --- a/15-adding-content.md +++ b/15-adding-content.md @@ -2,7 +2,7 @@ ### Adding Content -By now we did not really display anything but some examples to in our application and it is now time to make our app +By now we did not really display anything but some examples to in our application, and it is now time to make our app display some content. For example we could our app be able to display the Markdown files used in this tutorial as nicely rendered HTML Pages that can be viewed in the browser instead of the editor you are using. @@ -15,7 +15,7 @@ can use whatever you like. After installing Parsedown lets write a Markdownparser interface and an implementation using parsedown. -We only need one function that receives a string of Markdown and returns the HTML represantion (as a string as well). +We only need one function that receives a string of Markdown and returns the HTML representation (as a string as well). @@ -30,8 +30,8 @@ interface MarkdownParser } ``` -By the namespace you will already have guessed that I called placed in interface in a file calles MarkdownParser.php in -the src/Template folder. Lets put our Parsedown implementation right next to it in a file called ParsedownParser.php +By the namespace you will already have guessed that I placed in interface in a file calles MarkdownParser.php in +the src/Template folder. Let's put our Parsedown implementation right next to it in a file called ParsedownParser.php ```php addRoute('GET', '/page', [Page::class, 'list']); $r->addRoute('GET', '/page/{page}', [Page::class, 'show']); ``` -Here is my Implementation. If have added a little regex replacement in the show method that replaces the links to the +Here is my Implementation. I have added a little regex replacement in the show method that replaces the links to the next and previous chapter so that it works with our routing configuration. `src/Action/Page.php` @@ -244,9 +244,9 @@ class Page You can now navigate your Browser to [localhost:1235/page][http://localhost:1235/page] and try out if everything works. Of course this code is far from looking good. We heavily rely on the pages being files in the filesystem, and the action -should never be aware of the filesystem in the first place, also we have a lot of string replacements and other repetetive -code in the file. And phpstan is gonna scream at us a lot, but if we rewrite the code to satisfy all the checks we would -add even more lines to that simple class, so lets move on to the next chapter where we move all the logic to seperate +should never be aware of the filesystem in the first place, also we have a lot of string replacements and other repetitive +code in the file. And phpstan is going to scream at us a lot, but if we rewrite the code to satisfy all the checks we would +add even more lines to that simple class, so lets move on to the next chapter where we move all the logic to separate classes following our holy SOLID principles :) diff --git a/16-data-repository.md b/16-data-repository.md index d9a3218..1677f0a 100644 --- a/16-data-repository.md +++ b/16-data-repository.md @@ -2,32 +2,32 @@ ## Data Repository -At the end of the last chapter I mentioned being unhappy with our Pages action, because there is to much stuff happening -there. We are firstly receiving some Arguments, then we are using those to query the filesytem for the given page, +At the end of the last chapter I mentioned being unhappy with our Pages action, because there is too much stuff happening +there. We are firstly receiving some Arguments, then we are using those to query the filesystem for the given page, loading the specific file from the filesystem, rendering the markdown, passing the markdown to the template renderer, adding the resulting html to the response and then returning the response. -In order to make our pageaction independent from the filesystem and move the code that is responsible for reading the +In order to make our page-action independent of the filesystem and move the code that is responsible for reading the files to a better place I want to introduce the [Repository Pattern](https://designpatternsphp.readthedocs.io/en/latest/More/Repository/README.html). -I want to start by creating a class that represents the Data that is included in a page so that. For now I can spot +I want to start by creating a class that represents the Data that is included in a page so that. For now, I can spot three -distrinct attributes. +distinct attributes. -* the ID (or chapternumber) +* the ID (or chapter-number) * the title (or name) * the content -Currently all those properties are always available, but we might later be able to create new pages and store them, but +Currently, all those properties are always available, but we might later be able to create new pages and store them, but at that point in time we are not yet aware of the new available ID, so we should leave that property nullable. This allows -us to create an object without an id and let the code that actually saves the object to a persistant store define a +us to create an object without an id and let the code that actually saves the object to a persistent store define a valid id on saving. -Lets create an new Namespace called `Model` and put a `MarkdownPage.php` class in there: +Let's create an new Namespace called `Model` and put a `MarkdownPage.php` class in there: ```php