- You want encapsulation
- You have too many parameters for your class constructor.
- You want immutability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php namespace Helper; | |
| // This calculates the offset indexes for the Plugin | |
| class CollectionOffset | |
| { | |
| private $postsPerPage; | |
| private $page; | |
| public function __construct($postsPerPage = 10, $page = 1) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let bus = { | |
| messages: {}, | |
| on(message, callback) { | |
| if (!this.messages[message]) { | |
| this.messages[message] = []; | |
| } | |
| if (typeof callback === 'function') { | |
| this.messages[message].push(callback); | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var create = function(name) { | |
| var data = JSON.stringify({ | |
| title: name, author: 'Gemma' | |
| }) | |
| fetch('http://localhost:3000/posts', { | |
| method: 'POST', | |
| body: data, | |
| headers: { | |
| 'Accept': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.clear(); | |
| let model = { | |
| data: { | |
| state: 'waiting' | |
| }, | |
| set(type, value) { | |
| this.data[type] = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.clear(); | |
| let initstate = { | |
| attendees: [], | |
| likes: [], | |
| matches: [], | |
| meetings: [], | |
| } | |
| let addDelegate = (State, name) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bus = { | |
| messages: {}, | |
| on(message, callback) { | |
| if (this.messages[message] === undefined) { | |
| this.messages[message] = []; | |
| } | |
| this.messages[message].push(callback) | |
| }, | |
| emit(message, data) { | |
| if (this.messages[message] !== undefined) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var touchstartX = 0; | |
| var touchstartY = 0; | |
| var touchendX = 0; | |
| var touchendY = 0; | |
| var gesuredZone = document.getElementById('gesuredZone'); | |
| gesuredZone.addEventListener('touchstart', function(event) { | |
| touchstartX = event.screenX; | |
| touchstartY = event.screenY; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let delimiter = ':'; | |
| Object.keys(obj).reduce((a, b) => { | |
| return obj[b] !== undefined ? a.concat(b + delimiter + obj[b]) : a; | |
| }, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---- | |
| // Sass (v3.4.12) | |
| // Compass (v1.0.3) | |
| // ---- | |
| /* | |
| _ ______ _ __ _ | |
| (_) |___ / | | / _(_) | |
| _ ___ ___ / /_______ _| |__ ______| |_ ___ __ |